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;
16:
17: import org.araneaframework.Component;
18: import org.araneaframework.Environment;
19: import org.araneaframework.Scope;
20: import org.araneaframework.example.common.framework.ViewSelectorAware;
21: import org.araneaframework.example.main.business.data.IGeneralDAO;
22: import org.araneaframework.http.PopupWindowContext;
23: import org.araneaframework.integration.spring.SpringInjectionUtil;
24: import org.araneaframework.uilib.core.BaseUIWidget;
25: import org.springframework.beans.factory.BeanFactory;
26:
27: /**
28: * This is a base class for all widgets in this application.
29: *
30: * @author <a href="mailto:rein@araneaframework.org">Rein Raudjärv</a>
31: */
32: public abstract class TemplateBaseWidget extends BaseUIWidget implements
33: ViewSelectorAware {
34: protected BeanFactory getBeanFactory() {
35: return (BeanFactory) getEnvironment().getEntry(
36: BeanFactory.class);
37: }
38:
39: protected SecurityContext getSecCtx() {
40: return (SecurityContext) getEnvironment().getEntry(
41: SecurityContext.class);
42: }
43:
44: protected PopupWindowContext getPopupCtx() {
45: return (PopupWindowContext) getEnvironment().requireEntry(
46: PopupWindowContext.class);
47: }
48:
49: public IGeneralDAO getGeneralDAO() {
50: return (IGeneralDAO) getBeanFactory().getBean("generalDAO");
51: }
52:
53: public String getViewSelector() {
54: return viewSelector;
55: }
56:
57: public Component.Interface _getComponent() {
58: return new ComponentImpl();
59: }
60:
61: protected class ComponentImpl extends BaseUIWidget.ComponentImpl {
62: public void init(Scope scope, Environment env) {
63: SpringInjectionUtil.injectBeans(env,
64: TemplateBaseWidget.this);
65:
66: super.init(scope, env);
67: }
68: }
69: }
|