Source Code Cross Referenced for NewUserWizard.java in  » J2EE » wicket » wicket » examples » wizard » 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 » J2EE » wicket » wicket.examples.wizard 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: org.eclipse.jdt.ui.prefs 5004 2006-03-17 20:47:08 -0800 (Fri, 17 Mar
003:         * 2006) eelco12 $ $Revision: 5004 $ $Date: 2006-03-17 20:47:08 -0800 (Fri, 17
004:         * Mar 2006) $
005:         * 
006:         * ==============================================================================
007:         * Licensed under the Apache License, Version 2.0 (the "License"); you may not
008:         * use this file except in compliance with the License. You may obtain a copy of
009:         * the License at
010:         * 
011:         * http://www.apache.org/licenses/LICENSE-2.0
012:         * 
013:         * Unless required by applicable law or agreed to in writing, software
014:         * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
015:         * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
016:         * License for the specific language governing permissions and limitations under
017:         * the License.
018:         */
019:        package wicket.examples.wizard;
020:
021:        import java.util.Arrays;
022:        import java.util.Collections;
023:        import java.util.List;
024:
025:        import wicket.extensions.wizard.StaticContentStep;
026:        import wicket.extensions.wizard.Wizard;
027:        import wicket.extensions.wizard.WizardModel;
028:        import wicket.extensions.wizard.WizardStep;
029:        import wicket.extensions.wizard.WizardModel.ICondition;
030:        import wicket.markup.html.form.CheckBox;
031:        import wicket.markup.html.form.Form;
032:        import wicket.markup.html.form.FormComponent;
033:        import wicket.markup.html.form.ListMultipleChoice;
034:        import wicket.markup.html.form.RequiredTextField;
035:        import wicket.markup.html.form.TextField;
036:        import wicket.markup.html.form.validation.AbstractFormValidator;
037:        import wicket.markup.html.form.validation.EmailAddressPatternValidator;
038:        import wicket.model.CompoundPropertyModel;
039:        import wicket.model.IModel;
040:        import wicket.model.Model;
041:        import wicket.model.ResourceModel;
042:        import wicket.model.StringResourceModel;
043:
044:        /**
045:         * This wizard shows some basic form use. It uses custom panels for the form
046:         * elements, and a single domain object ({@link User}) as it's subject. Also,
047:         * {@link UserRolesStep the user roles step} is an optional step, that will only
048:         * be executed when assignRoles is true (and that value is edited in the
049:         * {@link UserDetailsStep user details step}).
050:         * 
051:         * @author Eelco Hillenius
052:         */
053:        public class NewUserWizard extends Wizard {
054:            /**
055:             * The confirmation step.
056:             */
057:            private final class ConfirmationStep extends StaticContentStep {
058:                /**
059:                 * Construct.
060:                 */
061:                public ConfirmationStep() {
062:                    super (true);
063:                    IModel userModel = new Model(user);
064:                    setTitleModel(new ResourceModel("confirmation.title"));
065:                    setSummaryModel(new StringResourceModel(
066:                            "confirmation.summary", this , userModel));
067:                    setContentModel(new StringResourceModel(
068:                            "confirmation.content", this , userModel));
069:                }
070:            }
071:
072:            /**
073:             * The user details step.
074:             */
075:            private final class UserDetailsStep extends WizardStep {
076:                /**
077:                 * Construct.
078:                 */
079:                public UserDetailsStep() {
080:                    super (new ResourceModel("userdetails.title"), null);
081:                    setSummaryModel(new StringResourceModel(
082:                            "userdetails.summary", this , new Model(user)));
083:                    add(new RequiredTextField("user.firstName"));
084:                    add(new RequiredTextField("user.lastName"));
085:                    add(new TextField("user.department"));
086:                    add(new CheckBox("assignRoles"));
087:                }
088:            }
089:
090:            /**
091:             * The user name step.
092:             */
093:            private final class UserNameStep extends WizardStep {
094:                /**
095:                 * Construct.
096:                 */
097:                public UserNameStep() {
098:                    super (new ResourceModel("username.title"),
099:                            new ResourceModel("username.summary"));
100:                    add(new RequiredTextField("user.userName"));
101:                    add(new RequiredTextField("user.email")
102:                            .add(EmailAddressPatternValidator.getInstance()));
103:                }
104:            }
105:
106:            /**
107:             * The user details step.
108:             */
109:            private final class UserRolesStep extends WizardStep implements 
110:                    ICondition {
111:                /**
112:                 * Construct.
113:                 */
114:                public UserRolesStep() {
115:                    super (new ResourceModel("userroles.title"), null);
116:                    setSummaryModel(new StringResourceModel(
117:                            "userroles.summary", this , new Model(user)));
118:                    final ListMultipleChoice rolesChoiceField = new ListMultipleChoice(
119:                            "user.roles", allRoles);
120:                    add(rolesChoiceField);
121:                    final TextField rolesSetNameField = new TextField(
122:                            "user.rolesSetName");
123:                    add(rolesSetNameField);
124:                    add(new AbstractFormValidator() {
125:                        public FormComponent[] getDependentFormComponents() {
126:                            // name and roles don't have anything to validate,
127:                            // so might as well just skip them here
128:                            return null;
129:                        }
130:
131:                        public void validate(Form form) {
132:                            String rolesInput = rolesChoiceField.getInput();
133:                            if (rolesInput != null && (!"".equals(rolesInput))) {
134:                                if ("".equals(rolesSetNameField.getInput())) {
135:                                    rolesSetNameField
136:                                            .error(
137:                                                    Collections
138:                                                            .singletonList("error.noSetNameForRoles"),
139:                                                    null);
140:                                }
141:                            }
142:                        }
143:                    });
144:                }
145:
146:                /**
147:                 * @see wicket.extensions.wizard.WizardModel.ICondition#evaluate()
148:                 */
149:                public boolean evaluate() {
150:                    return assignRoles;
151:                }
152:            }
153:
154:            /** cheap ass roles database. */
155:            private static final List allRoles = Arrays.asList(new String[] {
156:                    "admin", "user", "moderator", "joker", "slacker" });
157:
158:            /** Whether the assign roles step should be executed. */
159:            private boolean assignRoles = false;
160:
161:            /** The user we are editing. */
162:            private User user;
163:
164:            /**
165:             * Construct.
166:             * 
167:             * @param id
168:             *            The component id
169:             */
170:            public NewUserWizard(String id) {
171:                super (id);
172:
173:                // create a blank user
174:                user = new User();
175:
176:                setModel(new CompoundPropertyModel(this ));
177:                WizardModel model = new WizardModel();
178:                model.add(new UserNameStep());
179:                model.add(new UserDetailsStep());
180:                model.add(new UserRolesStep());
181:                model.add(new ConfirmationStep());
182:
183:                // initialize the wizard with the wizard model we just built
184:                init(model);
185:            }
186:
187:            /**
188:             * Gets user.
189:             * 
190:             * @return user
191:             */
192:            public User getUser() {
193:                return user;
194:            }
195:
196:            /**
197:             * Gets assignRoles.
198:             * 
199:             * @return assignRoles
200:             */
201:            public boolean isAssignRoles() {
202:                return assignRoles;
203:            }
204:
205:            /**
206:             * @see wicket.extensions.wizard.Wizard#onCancel()
207:             */
208:            public void onCancel() {
209:                setResponsePage(Index.class);
210:            }
211:
212:            /**
213:             * @see wicket.extensions.wizard.Wizard#onFinish()
214:             */
215:            public void onFinish() {
216:                setResponsePage(Index.class);
217:            }
218:
219:            /**
220:             * Sets assignRoles.
221:             * 
222:             * @param assignRoles
223:             *            assignRoles
224:             */
225:            public void setAssignRoles(boolean assignRoles) {
226:                this .assignRoles = assignRoles;
227:            }
228:
229:            /**
230:             * Sets user.
231:             * 
232:             * @param user
233:             *            user
234:             */
235:            public void setUser(User user) {
236:                this.user = user;
237:            }
238:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.