01: /**
02: * Copyright 2006-2007 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.blank;
16:
17: import org.araneaframework.core.ProxyEventListener;
18: import org.araneaframework.uilib.core.BaseUIWidget;
19: import org.araneaframework.uilib.form.FormWidget;
20: import org.araneaframework.uilib.form.control.TextControl;
21: import org.araneaframework.uilib.form.data.StringData;
22:
23: /**
24: * This is login widget. After receiving "successful" login event, it
25: * replaces itself on the call stack with real application root widget.
26: *
27: * @author Rein Raudjärv <reinra@ut.ee>
28: */
29: public class LoginWidget extends BaseUIWidget {
30: private static final long serialVersionUID = 1L;
31: /* Widget we will create and attach to this widget. */
32: private FormWidget form;
33:
34: protected void init() throws Exception {
35: setViewSelector("login");
36: setGlobalEventListener(new ProxyEventListener(this ));
37:
38: form = new FormWidget();
39: form.addElement("username", "#User", new TextControl(),
40: new StringData(), true);
41: form.addElement("password", "#Password", new TextControl(),
42: new StringData(), true);
43:
44: addWidget("loginForm", form);
45: }
46:
47: private void handleEventLogin() throws Exception {
48: if (form.convertAndValidate()) {
49: // validate login, start root flow
50: }
51: }
52:
53: private void handleEventJustLetMeIn() throws Exception {
54: getFlowCtx().replace(new RootWidget(), null);
55: }
56: }
|