Source Code Cross Referenced for SpaceFormPage.java in  » Issue-Tracking » jTrac » info » jtrac » wicket » 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 » Issue Tracking » jTrac » info.jtrac.wicket 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2002-2005 the original author or authors.
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:         */
016:
017:        package info.jtrac.wicket;
018:
019:        import info.jtrac.domain.Space;
020:        import info.jtrac.util.ValidationUtils;
021:        import java.util.List;
022:        import org.apache.wicket.behavior.HeaderContributor;
023:        import org.apache.wicket.markup.html.IHeaderContributor;
024:        import org.apache.wicket.markup.html.IHeaderResponse;
025:        import org.apache.wicket.markup.html.WebMarkupContainer;
026:        import org.apache.wicket.markup.html.WebPage;
027:        import org.apache.wicket.markup.html.form.Button;
028:        import org.apache.wicket.markup.html.form.CheckBox;
029:        import org.apache.wicket.markup.html.form.DropDownChoice;
030:        import org.apache.wicket.markup.html.form.Form;
031:        import org.apache.wicket.markup.html.form.IChoiceRenderer;
032:        import org.apache.wicket.markup.html.form.TextArea;
033:        import org.apache.wicket.markup.html.form.TextField;
034:        import org.apache.wicket.markup.html.link.Link;
035:        import org.apache.wicket.markup.html.panel.FeedbackPanel;
036:        import org.apache.wicket.model.BoundCompoundPropertyModel;
037:        import org.apache.wicket.validation.IValidatable;
038:        import org.apache.wicket.validation.validator.AbstractValidator;
039:
040:        /**
041:         * space edit form
042:         */
043:        public class SpaceFormPage extends BasePage {
044:
045:            private WebPage previous;
046:
047:            public void setPrevious(WebPage previous) {
048:                this .previous = previous;
049:            }
050:
051:            public SpaceFormPage() {
052:                Space space = new Space();
053:                space.getMetadata().initRoles();
054:                add(new SpaceForm("form", space));
055:            }
056:
057:            public SpaceFormPage(Space space) {
058:                add(new SpaceForm("form", space));
059:            }
060:
061:            /**
062:             * wicket form
063:             */
064:            private class SpaceForm extends Form {
065:
066:                private Space space;
067:                private Space copyFrom;
068:
069:                private JtracFeedbackMessageFilter filter;
070:
071:                public Space getSpace() {
072:                    return space;
073:                }
074:
075:                public void setSpace(Space space) {
076:                    this .space = space;
077:                }
078:
079:                public Space getCopyFrom() {
080:                    return copyFrom;
081:                }
082:
083:                public void setCopyFrom(Space copyFrom) {
084:                    this .copyFrom = copyFrom;
085:                }
086:
087:                public SpaceForm(String id, final Space space) {
088:
089:                    super (id);
090:
091:                    FeedbackPanel feedback = new FeedbackPanel("feedback");
092:                    filter = new JtracFeedbackMessageFilter();
093:                    feedback.setFilter(filter);
094:                    add(feedback);
095:
096:                    this .space = space;
097:                    final BoundCompoundPropertyModel model = new BoundCompoundPropertyModel(
098:                            this );
099:                    setModel(model);
100:
101:                    // delete button only if edit ======================================
102:                    Button delete = new Button("delete") {
103:                        @Override
104:                        public void onSubmit() {
105:                            String heading = localize("space_delete.confirm");
106:                            String warning = localize("space_delete.line3");
107:                            String line1 = localize("space_delete.line1");
108:                            String line2 = localize("space_delete.line2");
109:                            ConfirmPage confirm = new ConfirmPage(
110:                                    SpaceFormPage.this , heading, warning,
111:                                    new String[] { line1, line2 }) {
112:                                public void onConfirm() {
113:                                    getJtrac().removeSpace(space);
114:                                    // logged in user may have been allocated to this space
115:                                    SpaceFormPage.this .refreshPrincipal();
116:                                    setResponsePage(new SpaceListPage());
117:                                }
118:                            };
119:                            setResponsePage(confirm);
120:                        }
121:                    };
122:                    delete.setDefaultFormProcessing(false);
123:                    if (space.getId() <= 0) {
124:                        delete.setVisible(false);
125:                    }
126:                    add(delete);
127:                    // display name ====================================================
128:                    final TextField name = new TextField("space.name");
129:                    name.setRequired(true);
130:                    name.add(new ErrorHighlighter());
131:                    name.setOutputMarkupId(true);
132:                    add(name);
133:                    add(new HeaderContributor(new IHeaderContributor() {
134:                        public void renderHead(IHeaderResponse response) {
135:                            response
136:                                    .renderOnLoadJavascript("document.getElementById('"
137:                                            + name.getMarkupId() + "').focus()");
138:                        }
139:                    }));
140:                    // prefix Code =====================================================
141:                    TextField prefixCode = new TextField("space.prefixCode");
142:                    prefixCode.setRequired(true);
143:                    prefixCode.add(new ErrorHighlighter());
144:                    // validation: greater than 3 chars?
145:                    prefixCode.add(new AbstractValidator() {
146:                        protected void onValidate(IValidatable v) {
147:                            String s = (String) v.getValue();
148:                            if (s.length() < 3) {
149:                                error(v);
150:                            }
151:                        }
152:
153:                        @Override
154:                        protected String resourceKey() {
155:                            return "space_form.error.prefixCode.tooShort";
156:                        }
157:                    });
158:                    prefixCode.add(new AbstractValidator() {
159:                        protected void onValidate(IValidatable v) {
160:                            String s = (String) v.getValue();
161:                            if (s.length() > 10) {
162:                                error(v);
163:                            }
164:                        }
165:
166:                        @Override
167:                        protected String resourceKey() {
168:                            return "space_form.error.prefixCode.tooLong";
169:                        }
170:                    });
171:                    // validation: format ok?
172:                    prefixCode.add(new AbstractValidator() {
173:                        protected void onValidate(IValidatable v) {
174:                            String s = (String) v.getValue();
175:                            if (!ValidationUtils.isAllUpperCase(s)) {
176:                                error(v);
177:                            }
178:                        }
179:
180:                        @Override
181:                        protected String resourceKey() {
182:                            return "space_form.error.prefixCode.invalid";
183:                        }
184:                    });
185:                    // validation: does space already exist with same prefixCode ?
186:                    prefixCode.add(new AbstractValidator() {
187:                        protected void onValidate(IValidatable v) {
188:                            String s = (String) v.getValue();
189:                            Space temp = getJtrac().loadSpace(s);
190:                            if (temp != null && temp.getId() != space.getId()) {
191:                                error(v);
192:                            }
193:                        }
194:
195:                        @Override
196:                        protected String resourceKey() {
197:                            return "space_form.error.prefixCode.exists";
198:                        }
199:                    });
200:                    add(prefixCode);
201:                    // description =====================================================
202:                    add(new TextArea("space.description"));
203:                    // guest allowed ===================================================
204:                    add(new CheckBox("space.guestAllowed"));
205:                    // hide copy from option if edit ===================================
206:                    WebMarkupContainer hide = new WebMarkupContainer("hide");
207:                    if (space.getId() > 0) {
208:                        hide.setVisible(false);
209:                    } else {
210:                        List<Space> spaces = getJtrac().findAllSpaces();
211:                        DropDownChoice choice = new DropDownChoice("copyFrom",
212:                                spaces, new IChoiceRenderer() {
213:                                    public Object getDisplayValue(Object o) {
214:                                        return ((Space) o).getName();
215:                                    }
216:
217:                                    public String getIdValue(Object o, int i) {
218:                                        return ((Space) o).getId() + "";
219:                                    }
220:                                });
221:                        choice.setNullValid(true);
222:                        hide.add(choice);
223:                    }
224:                    add(hide);
225:                    // cancel link =====================================================
226:                    add(new Link("cancel") {
227:                        public void onClick() {
228:                            if (previous == null) {
229:                                setResponsePage(new OptionsPage());
230:                            } else {
231:                                if (previous instanceof  SpaceListPage) {
232:                                    ((SpaceListPage) previous)
233:                                            .setSelectedSpaceId(space.getId());
234:                                }
235:                                setResponsePage(previous);
236:                            }
237:                        }
238:                    });
239:                }
240:
241:                @Override
242:                protected void validate() {
243:                    filter.reset();
244:                    super .validate();
245:                }
246:
247:                @Override
248:                protected void onSubmit() {
249:                    if (copyFrom != null) {
250:                        Space temp = getJtrac().loadSpace(copyFrom.getId());
251:                        space.getMetadata().setXmlString(
252:                                temp.getMetadata().getXmlString());
253:                    }
254:                    setResponsePage(new SpaceFieldListPage(space, null,
255:                            previous));
256:                }
257:            }
258:
259:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.