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.contract;
16:
17: import org.apache.commons.logging.Log;
18: import org.apache.commons.logging.LogFactory;
19: import org.araneaframework.example.main.TemplateBaseWidget;
20: import org.araneaframework.example.main.business.model.PersonMO;
21: import org.araneaframework.example.main.web.person.PersonListWidget;
22: import org.araneaframework.framework.FlowContext;
23:
24: /**
25: * @author Rein Raudjärv <reinra@ut.ee>
26: */
27: public class ContractPersonEditWidget extends TemplateBaseWidget {
28:
29: private static final long serialVersionUID = 1L;
30: private static final Log log = LogFactory
31: .getLog(ContractPersonEditWidget.class);
32: private PersonMO person = null;
33:
34: public PersonMO getPerson() {
35: return person;
36: }
37:
38: public void setPerson(PersonMO person) {
39: this .person = person;
40: log.debug("Person with id of " + person.getId()
41: + " set to this contract");
42: }
43:
44: protected void init() throws Exception {
45: log.debug("TemplateContractPersonWidget init called");
46: setViewSelector("contract/contractPersonEdit");
47: }
48:
49: public void handleEventChoosePerson(String eventParameter)
50: throws Exception {
51: PersonListWidget newFlow = new PersonListWidget(false);
52: newFlow.setSelectOnly(true);
53: getFlowCtx().start(newFlow, new FlowContext.Handler() {
54: private static final long serialVersionUID = 1L;
55:
56: public void onFinish(Object returnValue) throws Exception {
57: Long id = (Long) returnValue;
58: setPerson((PersonMO) getGeneralDAO().getById(
59: PersonMO.class, id));
60: }
61:
62: public void onCancel() throws Exception {
63: }
64: });
65: }
66: }
|