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;
16:
17: import org.araneaframework.Environment;
18: import org.araneaframework.Widget;
19: import org.araneaframework.core.StandardEnvironment;
20: import org.araneaframework.example.main.SecurityContext;
21: import org.araneaframework.example.main.web.menu.MenuWidget;
22: import org.araneaframework.uilib.core.BaseUIWidget;
23:
24: /**
25: * This is root widget, always rendered after user has 'logged on'.
26: * It consists only of menu widget.
27: *
28: * @author <a href="mailto:rein@araneaframework.org">Rein Raudjärv</a>
29: */
30: public class RootWidget extends BaseUIWidget implements SecurityContext {
31: private static final long serialVersionUID = 1L;
32: private MenuWidget menuWidget;
33: private Widget topWidget;
34:
35: public RootWidget() {
36: }
37:
38: public RootWidget(Widget topWidget) {
39: this .topWidget = topWidget;
40: }
41:
42: protected void init() throws Exception {
43: menuWidget = new MenuWidget(topWidget);
44: addWidget("menu", menuWidget);
45: setViewSelector("root");
46:
47: if (topWidget == null)
48: menuWidget.selectMenuItem("Aranea_1_1");
49: topWidget = null;
50: }
51:
52: protected Environment getChildWidgetEnvironment() throws Exception {
53: return new StandardEnvironment(super
54: .getChildWidgetEnvironment(), SecurityContext.class,
55: this );
56: }
57:
58: public boolean hasPrivilege(String privilege) {
59: return false;
60: }
61:
62: public MenuWidget getMenuWidget() {
63: return menuWidget;
64: }
65:
66: public void logout() {
67: getFlowCtx().replace(new LoginWidget(), null);
68: }
69: }
|