01: /*
02: * Copyright 2002-2005 the original author or authors.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16:
17: package info.jtrac.wicket;
18:
19: import info.jtrac.domain.Config;
20: import org.apache.wicket.markup.html.basic.Label;
21: import org.apache.wicket.markup.html.form.Form;
22: import org.apache.wicket.markup.html.form.TextField;
23: import org.apache.wicket.markup.html.link.Link;
24: import org.apache.wicket.model.BoundCompoundPropertyModel;
25:
26: /**
27: * config value edit form
28: */
29: public class ConfigFormPage extends BasePage {
30:
31: public ConfigFormPage(String param, String value) {
32: add(new ConfigForm("form", param, value));
33: }
34:
35: /**
36: * wicket form
37: */
38: private class ConfigForm extends Form {
39:
40: private String param;
41:
42: private String value;
43:
44: public String getValue() {
45: return value;
46: }
47:
48: public void setValue(String value) {
49: this .value = value;
50: }
51:
52: public ConfigForm(String id, final String param,
53: final String value) {
54:
55: super (id);
56:
57: this .param = param;
58: this .value = value;
59:
60: final BoundCompoundPropertyModel model = new BoundCompoundPropertyModel(
61: this );
62: setModel(model);
63:
64: add(new Label("heading", localize("config." + param)));
65: add(new Label("param", param));
66:
67: add(new TextField("value"));
68:
69: // cancel ==========================================================
70: add(new Link("cancel") {
71: public void onClick() {
72: setResponsePage(new ConfigListPage(param));
73: }
74: });
75: }
76:
77: @Override
78: protected void onSubmit() {
79: getJtrac().storeConfig(new Config(param, value));
80: setResponsePage(new ConfigListPage(param));
81: }
82:
83: }
84:
85: }
|