Source Code Cross Referenced for SpaceFieldOptionPage.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.Field;
020:        import info.jtrac.domain.Space;
021:        import java.io.Serializable;
022:        import org.apache.wicket.markup.html.WebPage;
023:        import org.apache.wicket.markup.html.basic.Label;
024:        import org.apache.wicket.markup.html.form.Button;
025:        import org.apache.wicket.markup.html.form.Form;
026:        import org.apache.wicket.markup.html.form.TextField;
027:        import org.apache.wicket.markup.html.link.Link;
028:        import org.apache.wicket.markup.html.panel.FeedbackPanel;
029:        import org.apache.wicket.model.BoundCompoundPropertyModel;
030:        import org.apache.wicket.model.PropertyModel;
031:        import org.apache.wicket.validation.IValidatable;
032:        import org.apache.wicket.validation.validator.AbstractValidator;
033:
034:        /**
035:         * space field option edit form
036:         */
037:        public class SpaceFieldOptionPage extends BasePage {
038:
039:            private WebPage previous;
040:            private Space space;
041:
042:            private void addComponents(Field field, String key) {
043:                add(new SpaceFieldOptionForm("form", field, key));
044:            }
045:
046:            public SpaceFieldOptionPage(Space space, Field field, String key,
047:                    WebPage previous) {
048:                this .space = space;
049:                this .previous = previous;
050:                addComponents(field, key);
051:            }
052:
053:            /**
054:             * wicket form
055:             */
056:            private class SpaceFieldOptionForm extends Form {
057:
058:                private Field field;
059:                private String key;
060:
061:                public SpaceFieldOptionForm(String id, final Field field,
062:                        final String key) {
063:
064:                    super (id);
065:                    add(new FeedbackPanel("feedback"));
066:
067:                    this .field = field;
068:                    this .key = key;
069:
070:                    SpaceFieldOptionModel modelObject = new SpaceFieldOptionModel();
071:                    modelObject.setOption(field.getCustomValue(key));
072:                    final BoundCompoundPropertyModel model = new BoundCompoundPropertyModel(
073:                            modelObject);
074:                    setModel(model);
075:
076:                    // delete ==========================================================
077:                    Button delete = new Button("delete") {
078:                        @Override
079:                        public void onSubmit() {
080:                            int affectedCount = getJtrac()
081:                                    .loadCountOfRecordsHavingFieldWithValue(
082:                                            space, field, Integer.parseInt(key));
083:                            if (affectedCount > 0) {
084:                                String heading = localize("space_field_option_delete.confirm")
085:                                        + " : "
086:                                        + field.getCustomValue(key)
087:                                        + " [" + field.getLabel() + "]";
088:                                String warning = localize("space_field_option_delete.line3");
089:                                String line1 = localize("space_field_option_delete.line1");
090:                                String line2 = localize(
091:                                        "space_field_option_delete.line2",
092:                                        affectedCount + "");
093:                                ConfirmPage confirm = new ConfirmPage(
094:                                        SpaceFieldOptionPage.this , heading,
095:                                        warning, new String[] { line1, line2 }) {
096:                                    public void onConfirm() {
097:                                        field.getOptions().remove(key);
098:                                        getJtrac()
099:                                                .bulkUpdateFieldToNullForValue(
100:                                                        space, field,
101:                                                        Integer.parseInt(key));
102:                                        // database has been updated, if we don't do this
103:                                        // user may leave without committing metadata change       
104:                                        getJtrac().storeSpace(space);
105:                                        // synchronize metadata else when we save again we get Stale Object Exception
106:                                        space.setMetadata(getJtrac()
107:                                                .loadMetadata(
108:                                                        space.getMetadata()
109:                                                                .getId()));
110:                                        setResponsePage(new SpaceFieldFormPage(
111:                                                space, field, previous));
112:                                    }
113:                                };
114:                                setResponsePage(confirm);
115:                            } else {
116:                                // this is an unsaved space / field or there are no impacted items
117:                                field.getOptions().remove(key);
118:                                setResponsePage(new SpaceFieldFormPage(space,
119:                                        field, previous));
120:                            }
121:                        }
122:                    };
123:                    delete.setDefaultFormProcessing(false);
124:                    add(delete);
125:                    // heading label ===================================================
126:                    add(new Label("label", new PropertyModel(field, "label")));
127:                    // option ===========================================================
128:                    final TextField option = new TextField("option");
129:                    option.setRequired(true);
130:                    option.add(new ErrorHighlighter());
131:                    option.add(new AbstractValidator() {
132:                        protected void onValidate(IValidatable v) {
133:                            String s = (String) v.getValue();
134:                            if (field.hasOption(s)) {
135:                                error(v);
136:                            }
137:                        }
138:
139:                        @Override
140:                        protected String resourceKey() {
141:                            return "space_field_option_edit.error.exists";
142:                        }
143:                    });
144:                    add(option);
145:                    // cancel ==========================================================
146:                    add(new Link("cancel") {
147:                        public void onClick() {
148:                            setResponsePage(new SpaceFieldFormPage(space,
149:                                    field, previous));
150:                        }
151:                    });
152:                }
153:
154:                @Override
155:                protected void onSubmit() {
156:                    SpaceFieldOptionModel model = (SpaceFieldOptionModel) getModelObject();
157:                    field.addOption(key, model.getOption());
158:                    setResponsePage(new SpaceFieldFormPage(space, field,
159:                            previous));
160:                }
161:
162:            }
163:
164:            /**
165:             * custom form backing object that wraps Field
166:             * required for the create / edit use case
167:             */
168:            private class SpaceFieldOptionModel implements  Serializable {
169:
170:                private String option;
171:
172:                public String getOption() {
173:                    return option;
174:                }
175:
176:                public void setOption(String option) {
177:                    this.option = option;
178:                }
179:
180:            }
181:
182:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.