01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.wicket.util.tester.apps_1;
18:
19: import org.apache.wicket.Page;
20: import org.apache.wicket.markup.html.WebPage;
21: import org.apache.wicket.markup.html.form.Form;
22: import org.apache.wicket.markup.html.form.RequiredTextField;
23: import org.apache.wicket.model.Model;
24: import org.apache.wicket.model.PropertyModel;
25:
26: /**
27: *
28: * @author Juergen Donnerstag
29: */
30: public class CreateBook extends WebPage {
31: private static final long serialVersionUID = 1L;
32:
33: private final Book book = new Book(null, null);
34:
35: /**
36: *
37: */
38: public CreateBook() {
39: add(new CreateForm("createForm"));
40: }
41:
42: /**
43: *
44: * @author Juergen Donnerstag
45: */
46: public class CreateForm extends Form {
47: private static final long serialVersionUID = 1L;
48:
49: /**
50: *
51: * @param id
52: */
53: public CreateForm(String id) {
54: super (id);
55:
56: // label model here comes from java
57: add(new RequiredTextField("id", new PropertyModel(book,
58: "id")).setLabel(new Model("id")));
59: // label model here comes from CreateBook.properties
60: add(new RequiredTextField("name", new PropertyModel(book,
61: "name")));
62: }
63:
64: /**
65: * @see org.apache.wicket.markup.html.form.Form#onSubmit()
66: */
67: public void onSubmit() {
68: try {
69: Page page = new SuccessPage();
70: page.info(getString("book.save.success",
71: new Model(book)));
72: setResponsePage(page);
73: } finally {
74: getPage().getPageMap().remove(getPage());
75: }
76: }
77: }
78: }
|