01: /**
02: * Copyright 2006 Webmedia Group Ltd.
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: **/package org.araneaframework.example.main.web.person;
16:
17: import org.araneaframework.example.main.TemplateBaseWidget;
18: import org.araneaframework.example.main.business.model.PersonMO;
19: import org.araneaframework.uilib.form.BeanFormWidget;
20: import org.araneaframework.uilib.form.control.DateControl;
21: import org.araneaframework.uilib.form.control.DisplayControl;
22: import org.araneaframework.uilib.form.control.FloatControl;
23:
24: /**
25: * This widget is for displaying a person.
26: * It cancels current call only.
27: *
28: * @author <a href="mailto:rein@araneaframework.org">Rein Raudjärv</a>
29: */
30: public class PersonViewWidget extends TemplateBaseWidget {
31: private static final long serialVersionUID = 1L;
32: private Long personId = null;
33:
34: /**
35: * @param personId Person's Id.
36: */
37: public PersonViewWidget(Long id) {
38: super ();
39: this .personId = id;
40: }
41:
42: protected void init() throws Exception {
43: setViewSelector("person/personView");
44:
45: BeanFormWidget personForm = new BeanFormWidget(PersonMO.class);
46: personForm.addBeanElement("name", "#First name",
47: new DisplayControl(), true);
48: personForm.addBeanElement("surname", "#Last name",
49: new DisplayControl(), false);
50: personForm.addBeanElement("phone", "#Phone no",
51: new DisplayControl(), true);
52: personForm.addBeanElement("birthdate", "#Birthdate",
53: new DateControl(), false);
54: personForm.addBeanElement("salary", "#Salary",
55: new FloatControl(), false);
56: personForm.readFromBean(getGeneralDAO().getById(PersonMO.class,
57: personId));
58:
59: addWidget("personForm", personForm);
60: }
61:
62: public void handleEventReturn(String eventParameter)
63: throws Exception {
64: getFlowCtx().cancel();
65: }
66: }
|