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.core.ProxyEventListener;
20: import org.araneaframework.example.main.TemplateBaseWidget;
21: import org.araneaframework.example.main.business.model.CompanyMO;
22: import org.araneaframework.example.main.web.company.CompanyListWidget;
23: import org.araneaframework.framework.FlowContext;
24:
25: /**
26: * @author Rein Raudjärv <reinra@ut.ee>
27: */
28: public class ContractCompanyEditWidget extends TemplateBaseWidget {
29: private static final long serialVersionUID = 1L;
30: private static final Log log = LogFactory
31: .getLog(ContractCompanyEditWidget.class);
32: private CompanyMO company = null;
33:
34: public CompanyMO getCompany() {
35: return company;
36: }
37:
38: public void setCompany(CompanyMO company) {
39: this .company = company;
40: }
41:
42: protected void init() throws Exception {
43: log.debug("TemplateContractCompanyWidget init called");
44: setViewSelector("contract/contractCompanyEdit");
45: addEventListener("chooseCompany", new ProxyEventListener(this ));
46: }
47:
48: public void handleEventChooseCompany(String eventParameter)
49: throws Exception {
50: getFlowCtx().start(new CompanyListWidget(false),
51: new FlowContext.Handler() {
52: private static final long serialVersionUID = 1L;
53:
54: public void onFinish(Object returnValue)
55: throws Exception {
56: Long id = (Long) returnValue;
57: setCompany((CompanyMO) getGeneralDAO().getById(
58: CompanyMO.class, id));
59: log.debug("Company with id of " + id
60: + " set to this contract");
61: }
62:
63: public void onCancel() throws Exception {
64: }
65: });
66: }
67: }
|