Source Code Cross Referenced for SimpleFormWidget.java in  » Web-Framework » aranea-mvc-1.1.1 » org » araneaframework » example » main » web » sample » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Framework » aranea mvc 1.1.1 » org.araneaframework.example.main.web.sample 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Copyright 2006 Webmedia Group Ltd.
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *  http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         **/package org.araneaframework.example.main.web.sample;
016:
017:        import java.util.Date;
018:        import org.araneaframework.example.main.TemplateBaseWidget;
019:        import org.araneaframework.uilib.event.ProxyOnClickEventListener;
020:        import org.araneaframework.uilib.form.FormElement;
021:        import org.araneaframework.uilib.form.FormWidget;
022:        import org.araneaframework.uilib.form.constraint.NotEmptyConstraint;
023:        import org.araneaframework.uilib.form.control.ButtonControl;
024:        import org.araneaframework.uilib.form.control.CheckboxControl;
025:        import org.araneaframework.uilib.form.control.DateControl;
026:        import org.araneaframework.uilib.form.control.DateTimeControl;
027:        import org.araneaframework.uilib.form.control.FloatControl;
028:        import org.araneaframework.uilib.form.control.TextControl;
029:        import org.araneaframework.uilib.form.control.TimeControl;
030:        import org.araneaframework.uilib.form.data.BigDecimalData;
031:        import org.araneaframework.uilib.form.data.BooleanData;
032:        import org.araneaframework.uilib.form.data.DateData;
033:        import org.araneaframework.uilib.form.data.StringData;
034:
035:        /**
036:         * Simple form component. A form with one checkbox, one textbox and 
037:         * three kinds of different timeinputs (DateInput, Timeinput and 
038:         * DateTimeInput) and a button.
039:         * 
040:         * @author Jevgeni Kabanov (ekabanov <i>at</i> araneaframework <i>dot</i> org)
041:         */
042:        public class SimpleFormWidget extends TemplateBaseWidget {
043:            private static final long serialVersionUID = 1L;
044:            private FormWidget simpleForm;
045:
046:            /**
047:             * Builds the form.
048:             */
049:            protected void init() throws Exception {
050:                setViewSelector("sample/simpleForm");
051:
052:                // creation of new form
053:                simpleForm = new FormWidget();
054:
055:                // Now that we have created a form, we will need to add form elements.
056:                // form elements consist of four basic things - label, Control that implements
057:                // form element functionality and Data holding values that form element can have.
058:                // Note that the first sample with FormWidget's createElement method is not the
059:                // way form elements are usually added to the form, but rather emphasises the
060:                // fact that everything you add to FormWidget is a FormElement.
061:
062:                // createElement(String labelId, Control control, Data data, boolean mandatory)
063:                FormElement el = simpleForm.createElement("common.Textbox",
064:                        new TextControl(), new StringData(), false);
065:                simpleForm.addElement("textbox1", el);
066:
067:                // and here we add form elements to form without the extra step taken previously. 
068:                simpleForm.addElement("checkbox1", "Checkbox",
069:                        new CheckboxControl(), new BooleanData(), false);
070:                simpleForm.addElement("dateTime", "common.datetime",
071:                        new DateTimeControl(), new DateData(), false);
072:                simpleForm.addElement("time", "common.time", new TimeControl(),
073:                        new DateData(), false);
074:                simpleForm.addElement("date", "common.date", new DateControl(),
075:                        new DateData(), false);
076:                simpleForm.addElement("number", "common.float",
077:                        new FloatControl(), new BigDecimalData(), false);
078:                // require the number input field to be filled. It could have been achieved already
079:                // on formelement creation by setting mandatory attribute to true
080:                simpleForm.getElement("number").setConstraint(
081:                        new NotEmptyConstraint());
082:                // sets initial value of form element
083:                simpleForm.setValueByFullName("dateTime", new Date());
084:
085:                // now we construct a button, that is also Control. Reason why we cannot just add it
086:                // to form is obvious, we want to add a specific listener to button before.
087:                ButtonControl button = new ButtonControl();
088:                button.addOnClickEventListener(new ProxyOnClickEventListener(
089:                        this , "testSimpleForm"));
090:                // add the button to form. As the button does not hold any value, Data will be null.
091:                simpleForm.addElement("button", "#Button", button, null, false);
092:
093:                // the usual, add the created widget to main widget.
094:                addWidget("simpleForm", simpleForm);
095:            }
096:
097:            /**
098:             * A test action, invoked when button is pressed. It adds the values of 
099:             * formelements to message context, and they end up at the top of user screen
100:             * at the end of the request.
101:             */
102:            public void handleEventTestSimpleForm() throws Exception {
103:                // if form is not invalid, do not try to show form element values 
104:                // (error messages are added automatically to the messagecontext 
105:                // though, user will not be without feedback)
106:                if (simpleForm.convertAndValidate()) {
107:                    // long way to check form element value ...
108:                    getMessageCtx().showInfoMessage(
109:                            "Checkbox value is: "
110:                                    + ((FormElement) simpleForm
111:                                            .getElement("checkbox1")).getData()
112:                                            .getValue());
113:                    // and a shorter one
114:                    getMessageCtx()
115:                            .showInfoMessage(
116:                                    "Textbox value is: "
117:                                            + simpleForm
118:                                                    .getValueByFullName("textbox1"));
119:                    getMessageCtx()
120:                            .showInfoMessage(
121:                                    "DateTime value is: "
122:                                            + simpleForm
123:                                                    .getValueByFullName("dateTime"));
124:                    getMessageCtx().showInfoMessage(
125:                            "Time value is: "
126:                                    + simpleForm.getValueByFullName("time"));
127:                    getMessageCtx().showInfoMessage(
128:                            "Date value is: "
129:                                    + simpleForm.getValueByFullName("date"));
130:                    getMessageCtx().showInfoMessage(
131:                            "Number value is: "
132:                                    + simpleForm.getValueByFullName("number"));
133:                }
134:            }
135:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.