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


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         *
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         *
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.wicket.markup.html.form;
018:
019:        import org.apache.wicket.markup.ComponentTag;
020:        import org.apache.wicket.model.IModel;
021:        import org.apache.wicket.version.undo.Change;
022:
023:        /**
024:         * A form button.
025:         * <p>
026:         * Within a form, you can nest Button components. Note that you don't have to do
027:         * this to let the form work (a simple &lt;input type="submit".. suffices), but
028:         * if you want to have different kinds of submit behavior it might be a good
029:         * idea to use Buttons.
030:         * </p>
031:         * <p>
032:         * The model property is used to set the &quot;value&quot; attribute. It will
033:         * thus be the label of the button that shows up for end users. If you want the
034:         * attribute to keep it's markup attribute value, don't provide a model, or let
035:         * it return an empty string.
036:         * </p>
037:         * <p>
038:         * When you add a Wicket Button to a form, and that button is clicked, by
039:         * default the button's onSubmit method is called first, and after that the
040:         * form's onSubmit method is called. If you want to change this (e.g. you don't
041:         * want to call the form's onSubmit method, or you want it called before the
042:         * button's onSubmit method), you can override Form.delegateSubmit.
043:         * </p>
044:         * <p>
045:         * One other option you should know of is the 'defaultFormProcessing' property
046:         * of Button components. When you set this to false (default is true), all
047:         * validation and formupdating is bypassed and the onSubmit method of that
048:         * button is called directly, and the onSubmit method of the parent form is not
049:         * called. A common use for this is to create a cancel button.
050:         * </p>
051:         * 
052:         * @author Jonathan Locke
053:         * @author Eelco Hillenius
054:         */
055:        public class Button extends FormComponent implements 
056:                IFormSubmittingComponent {
057:            private static final long serialVersionUID = 1L;
058:
059:            /**
060:             * If false, all standard processing like validating and model updating is
061:             * skipped.
062:             */
063:            private boolean defaultFormProcessing = true;
064:
065:            /**
066:             * Constructor without a model. Buttons without models leave the markup
067:             * attribute &quot;value&quot;. Provide a model if you want to set the
068:             * button's label dynamically.
069:             * 
070:             * @see org.apache.wicket.Component#Component(String)
071:             */
072:            public Button(String id) {
073:                super (id);
074:                setVersioned(true);
075:                setOutputMarkupId(true);
076:            }
077:
078:            /**
079:             * Constructor taking an model for rendering the 'label' of the button (the
080:             * value attribute of the input/button tag). Use a
081:             * {@link org.apache.wicket.model.StringResourceModel} for a localized value.
082:             * 
083:             * @param id
084:             *            Component id
085:             * @param model
086:             *            The model property is used to set the &quot;value&quot;
087:             *            attribute. It will thus be the label of the button that shows
088:             *            up for end users. If you want the attribute to keep it's
089:             *            markup attribute value, don't provide a model, or let it
090:             *            return an empty string.
091:             */
092:            public Button(final String id, final IModel model) {
093:                super (id, model);
094:                setVersioned(true);
095:                setOutputMarkupId(true);
096:            }
097:
098:            /**
099:             * Override of the default initModel behaviour. This component <strong>will
100:             * not</strong> use any compound model a parent, but only a model that is
101:             * explicitly set.
102:             * 
103:             * @see org.apache.wicket.Component#initModel()
104:             */
105:            protected IModel initModel() {
106:                return null;
107:            }
108:
109:            /**
110:             * Gets the defaultFormProcessing property. When false (default is true),
111:             * all validation and formupdating is bypassed and the onSubmit method of
112:             * that button is called directly, and the onSubmit method of the parent
113:             * form is not called. A common use for this is to create a cancel button.
114:             * 
115:             * @return defaultFormProcessing
116:             */
117:            public final boolean getDefaultFormProcessing() {
118:                return defaultFormProcessing;
119:            }
120:
121:            /**
122:             * Sets the defaultFormProcessing property. When false (default is true),
123:             * all validation and form updating is bypassed and the onSubmit method of
124:             * that button is called directly, and the onSubmit method of the parent
125:             * form is not called. A common use for this is to create a cancel button.
126:             * 
127:             * @param defaultFormProcessing
128:             *            defaultFormProcessing
129:             * @return This
130:             */
131:            public final Button setDefaultFormProcessing(
132:                    boolean defaultFormProcessing) {
133:                if (this .defaultFormProcessing != defaultFormProcessing) {
134:                    addStateChange(new Change() {
135:                        private static final long serialVersionUID = 1L;
136:
137:                        boolean formerValue = Button.this .defaultFormProcessing;
138:
139:                        public void undo() {
140:                            Button.this .defaultFormProcessing = formerValue;
141:                        }
142:
143:                        public String toString() {
144:                            return "DefaultFormProcessingChange[component: "
145:                                    + getPath() + ", default processing: "
146:                                    + formerValue + "]";
147:                        }
148:                    });
149:                }
150:
151:                this .defaultFormProcessing = defaultFormProcessing;
152:                return this ;
153:            }
154:
155:            /**
156:             * This method does nothing, as any model of a button is only used to
157:             * display the button's label (by setting it's markup attribute
158:             * &quot;value&quot;).
159:             * 
160:             * @see org.apache.wicket.markup.html.form.FormComponent#updateModel()
161:             */
162:            public void updateModel() {
163:            }
164:
165:            /**
166:             * Gets any script that should rendered as the &quot;onclick&quot; attribute
167:             * of the button. Returns null by default, override this method to provide
168:             * any script.
169:             * 
170:             * @return Any onClick JavaScript that should be used, returns null by
171:             *         default
172:             */
173:            protected String getOnClickScript() {
174:                return null;
175:            }
176:
177:            /**
178:             * Processes the component tag. A <tt>value</tt> attribute is added with
179:             * the value of the model object, if available. An <tt>onclick</tt>
180:             * attribute is added if the subclass specified javascript.
181:             * 
182:             * <p>
183:             * <b>NOTE</b>. For a <tt>&lt;button&gt;</tt> the <tt>value</tt>
184:             * attribute is not rendered, markup needs to be added within the button
185:             * to display the button's label.
186:             * </p>
187:             * 
188:             * @param tag
189:             *            Tag to modify
190:             * @see org.apache.wicket.Component#onComponentTag(ComponentTag)
191:             */
192:            protected void onComponentTag(final ComponentTag tag) {
193:                // Default handling for component tag
194:                super .onComponentTag(tag);
195:
196:                String name = tag.getName();
197:
198:                try {
199:                    String value = getModelObjectAsString();
200:                    if (value != null && !"".equals(value)) {
201:                        tag.put("value", value);
202:                    }
203:                } catch (Exception e) {
204:                    // ignore.
205:                }
206:
207:                // If the subclass specified javascript, use that
208:                final String onClickJavaScript = getOnClickScript();
209:                if (onClickJavaScript != null) {
210:                    tag.put("onclick", onClickJavaScript);
211:                }
212:            }
213:
214:            /**
215:             * Override this method to provide special submit handling in a multi-button
216:             * form. It is called whenever the user clicks this particular button.
217:             */
218:            public void onSubmit() {
219:            }
220:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.