Source Code Cross Referenced for DropDownChoice.java in  » J2EE » wicket » wicket » markup » html » form » 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.markup.html.form 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: DropDownChoice.java 5755 2006-05-16 14:14:37 +0000 (Tue, 16 May 2006)
003:         * joco01 $ $Revision: 469206 $ $Date: 2006-05-16 14:14:37 +0000 (Tue, 16 May
004:         * 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.markup.html.form;
020:
021:        import java.util.List;
022:
023:        import wicket.markup.ComponentTag;
024:        import wicket.model.IModel;
025:
026:        /**
027:         * A choice implemented as a dropdown menu/list.
028:         * <p>
029:         * Java:
030:         * 
031:         * <pre>
032:         * List SITES = Arrays.asList(new String[] { &quot;The Server Side&quot;, &quot;Java Lobby&quot;, &quot;Java.Net&quot; });
033:         * 
034:         * // Add a dropdown choice component that uses Input's 'site' property to designate the
035:         * // current selection, and that uses the SITES list for the available options.
036:         * // Note that when the selection is null, Wicket will lookup a localized string to
037:         * // represent this null with key: &quot;id + '.null'&quot;. In this case, this is 'site.null'
038:         * // which can be found in DropDownChoicePage.properties
039:         * form.add(new DropDownChoice(&quot;site&quot;, SITES));
040:         * </pre>
041:         * 
042:         * HTML:
043:         * 
044:         * <pre>
045:         *   	&lt;select wicket:id=&quot;site&quot;&gt;
046:         *   		&lt;option&gt;site 1&lt;/option&gt;
047:         *   		&lt;option&gt;site 2&lt;/option&gt;
048:         *   	&lt;/select&gt;
049:         * </pre>
050:         * 
051:         * </p>
052:         * 
053:         * <p>
054:         * You can can extend this class and override method
055:         * wantOnSelectionChangedNotifications() to force server roundtrips on each
056:         * selection change.
057:         * </p>
058:         * 
059:         * @author Jonathan Locke
060:         * @author Eelco Hillenius
061:         * @author Johan Compagner
062:         */
063:        public class DropDownChoice extends AbstractSingleSelectChoice
064:                implements  IOnChangeListener {
065:            private static final long serialVersionUID = 1L;
066:
067:            /**
068:             * @see wicket.markup.html.form.AbstractChoice#AbstractChoice(String)
069:             */
070:            public DropDownChoice(final String id) {
071:                super (id);
072:            }
073:
074:            /**
075:             * @see wicket.markup.html.form.AbstractChoice#AbstractChoice(String, List)
076:             */
077:            public DropDownChoice(final String id, final List choices) {
078:                super (id, choices);
079:            }
080:
081:            /**
082:             * @see wicket.markup.html.form.AbstractChoice#AbstractChoice(String,
083:             *      List,IChoiceRenderer)
084:             */
085:            public DropDownChoice(final String id, final List data,
086:                    final IChoiceRenderer renderer) {
087:                super (id, data, renderer);
088:            }
089:
090:            /**
091:             * @see wicket.markup.html.form.AbstractChoice#AbstractChoice(String,
092:             *      IModel, List)
093:             */
094:            public DropDownChoice(final String id, IModel model,
095:                    final List choices) {
096:                super (id, model, choices);
097:            }
098:
099:            /**
100:             * @see wicket.markup.html.form.AbstractChoice#AbstractChoice(String,
101:             *      IModel, List, IChoiceRenderer)
102:             */
103:            public DropDownChoice(final String id, IModel model,
104:                    final List data, final IChoiceRenderer renderer) {
105:                super (id, model, data, renderer);
106:            }
107:
108:            /**
109:             * @see wicket.markup.html.form.AbstractChoice#AbstractChoice(String,
110:             *      IModel)
111:             */
112:            public DropDownChoice(String id, IModel choices) {
113:                super (id, choices);
114:            }
115:
116:            /**
117:             * @see wicket.markup.html.form.AbstractChoice#AbstractChoice(String,
118:             *      IModel,IModel)
119:             */
120:            public DropDownChoice(String id, IModel model, IModel choices) {
121:                super (id, model, choices);
122:            }
123:
124:            /**
125:             * @see wicket.markup.html.form.AbstractChoice#AbstractChoice(String,
126:             *      IModel,IChoiceRenderer)
127:             */
128:            public DropDownChoice(String id, IModel choices,
129:                    IChoiceRenderer renderer) {
130:                super (id, choices, renderer);
131:            }
132:
133:            /**
134:             * @see wicket.markup.html.form.AbstractChoice#AbstractChoice(String,
135:             *      IModel, IModel,IChoiceRenderer)
136:             */
137:            public DropDownChoice(String id, IModel model, IModel choices,
138:                    IChoiceRenderer renderer) {
139:                super (id, model, choices, renderer);
140:            }
141:
142:            /**
143:             * Called when a selection changes.
144:             */
145:            public final void onSelectionChanged() {
146:                convert();
147:                updateModel();
148:                onSelectionChanged(getModelObject());
149:            }
150:
151:            /**
152:             * Processes the component tag.
153:             * 
154:             * @param tag
155:             *            Tag to modify
156:             * @see wicket.Component#onComponentTag(wicket.markup.ComponentTag)
157:             */
158:            protected void onComponentTag(final ComponentTag tag) {
159:                checkComponentTag(tag, "select");
160:
161:                // Should a roundtrip be made (have onSelectionChanged called) when the
162:                // selection changed?
163:                if (wantOnSelectionChangedNotifications()) {
164:                    // url that points to this components IOnChangeListener method
165:                    final CharSequence url = urlFor(IOnChangeListener.INTERFACE);
166:
167:                    Form form = (Form) findParent(Form.class);
168:                    if (form != null) {
169:                        tag.put("onchange", form.getJsForInterfaceUrl(url));
170:                    } else {
171:                        tag
172:                                .put(
173:                                        "onchange",
174:                                        "window.location.href='"
175:                                                + url
176:                                                + "&"
177:                                                + getInputName()
178:                                                + "=' + this.options[this.selectedIndex].value;");
179:                    }
180:                }
181:
182:                super .onComponentTag(tag);
183:            }
184:
185:            /**
186:             * Template method that can be overriden by clients that implement
187:             * IOnChangeListener to be notified by onChange events of a select element.
188:             * This method does nothing by default.
189:             * <p>
190:             * Called when a option is selected of a dropdown list that wants to be
191:             * notified of this event. This method is to be implemented by clients that
192:             * want to be notified of selection events.
193:             * 
194:             * @param newSelection
195:             *            The newly selected object of the backing model NOTE this is
196:             *            the same as you would get by calling getModelObject() if the
197:             *            new selection were current
198:             */
199:            protected void onSelectionChanged(final Object newSelection) {
200:            }
201:
202:            /**
203:             * Whether this component's onSelectionChanged event handler should called
204:             * using javascript if the selection changes. If true, a roundtrip will be
205:             * generated with each selection change, resulting in the model being
206:             * updated (of just this component) and onSelectionChanged being called.
207:             * This method returns false by default.
208:             * 
209:             * @return True if this component's onSelectionChanged event handler should
210:             *         called using javascript if the selection changes
211:             */
212:            protected boolean wantOnSelectionChangedNotifications() {
213:                return false;
214:            }
215:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.