Source Code Cross Referenced for Form.java in  » Ajax » dwr » jsx3 » gui » 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 » Ajax » dwr » jsx3.gui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005 Joe Walker
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:        package jsx3.gui;
017:
018:        import org.directwebremoting.ScriptBuffer;
019:        import org.directwebremoting.proxy.ScriptProxy;
020:        import org.directwebremoting.proxy.io.Context;
021:
022:        /**
023:         * Mixin interface. Contains methods and constants encapsulating the functionality of an HTML form control.
024:         * @author Joe Walker [joe at getahead dot org]
025:         * @author DRAPGEN - Dwr Reverse Ajax Proxy GENerator
026:         */
027:        public class Form extends jsx3.lang.Object {
028:            /**
029:             * All reverse ajax proxies need context to work from
030:             * @param scriptProxy The place we are writing scripts to
031:             * @param context The script that got us to where we are now
032:             */
033:            public Form(Context context, String extension,
034:                    ScriptProxy scriptProxy) {
035:                super (context, extension, scriptProxy);
036:            }
037:
038:            /**
039:             * #a8a8b5 (default)
040:             */
041:            public static final String DEFAULTDISABLEDCOLOR = "#a8a8b5";
042:
043:            /**
044:             * #d8d8e5 (default)
045:             */
046:            public static final String DEFAULTDISABLEDBACKGROUNDCOLOR = "#d8d8e5";
047:
048:            /**
049:             * Value for the validation state field indicating that the value of the form field is invalid.
050:             */
051:            public static final int STATEINVALID = 0;
052:
053:            /**
054:             * Value for the validation state field indicating that the value of the form field is valid.
055:             */
056:            public static final int STATEVALID = 1;
057:
058:            /**
059:             * Value for the enabled field indicating that the form field is disabled.
060:             */
061:            public static final int STATEDISABLED = 0;
062:
063:            /**
064:             * Value for the enabled field indicating that the form field is enabled.
065:             */
066:            public static final int STATEENABLED = 1;
067:
068:            /**
069:             * Value for the required field indicating that the form field is optional.
070:             */
071:            public static final int OPTIONAL = 0;
072:
073:            /**
074:             * Value for the required field indicating that the form field is required.
075:             */
076:            public static final int REQUIRED = 1;
077:
078:            /**
079:             * Binds the given key sequence to a callback function. Any object that has a key binding (specified with
080:            setKeyBinding()) will call this method when painted to register the key sequence with an appropriate
081:            ancestor of this form control. Any key down event that bubbles up to the ancestor without being intercepted
082:            and matches the given key sequence will invoke the given callback function.
083:
084:            As of 3.2: The hot key will be registered with the first ancestor found that is either a
085:            jsx3.gui.Window, a jsx3.gui.Dialog, or the root block of a jsx3.app.Server.
086:             * @param fctCallback JavaScript function to execute when the given sequence is keyed by the user.
087:             * @param strKeys a plus-delimited ('+') key sequence such as <code>ctrl+s</code> or
088:            <code>ctrl+shift+alt+h</code> or <code>shift+a</code>, etc. Any combination of shift, ctrl, and alt are
089:            supported, including none. Also supported as the final token are <code>enter</code>, <code>esc</code>,
090:            <code>tab</code>, <code>del</code>, and <code>space</code>. To specify the final token as a key code, the
091:            last token can be the key code contained in brackets, <code>[13]</code>.
092:             * @return the registered hot key.
093:             */
094:            @SuppressWarnings("unchecked")
095:            public jsx3.gui.HotKey doKeyBinding(
096:                    org.directwebremoting.proxy.CodeBlock fctCallback,
097:                    String strKeys) {
098:                String extension = "doKeyBinding(\"" + fctCallback + "\", \""
099:                        + strKeys + "\").";
100:                try {
101:                    java.lang.reflect.Constructor<jsx3.gui.HotKey> ctor = jsx3.gui.HotKey.class
102:                            .getConstructor(Context.class, String.class,
103:                                    ScriptProxy.class);
104:                    return ctor.newInstance(this , extension, getScriptProxy());
105:                } catch (Exception ex) {
106:                    throw new IllegalArgumentException("Unsupported type: "
107:                            + jsx3.gui.HotKey.class.getName());
108:                }
109:            }
110:
111:            /**
112:             * Returns the key binding that when keyed will fire the execute event for this control.
113:             * @param callback plus-delimited (e.g.,'+') key sequence such as ctrl+s or ctrl+shift+alt+h or shift+a, etc
114:             */
115:            @SuppressWarnings("unchecked")
116:            public void getKeyBinding(
117:                    org.directwebremoting.proxy.Callback<String> callback) {
118:                ScriptBuffer script = new ScriptBuffer();
119:                String callbackPrefix = "";
120:
121:                if (callback != null) {
122:                    callbackPrefix = "var reply = ";
123:                }
124:
125:                script.appendCall(callbackPrefix + getContextPath()
126:                        + "getKeyBinding");
127:
128:                if (callback != null) {
129:                    String key = org.directwebremoting.extend.CallbackHelper
130:                            .saveCallback(callback, String.class);
131:                    script
132:                            .appendCall("__System.activateCallback", key,
133:                                    "reply");
134:                }
135:
136:                getScriptProxy().addScript(script);
137:            }
138:
139:            /**
140:             * Sets the key binding that when keyed will fire the bound execute (jsx3.gui.Interactive.EXECUTE)
141:            event for this control.
142:             * @param strSequence plus-delimited (e.g.,'+') key sequence such as ctrl+s or ctrl+shift+alt+h or shift+a, etc
143:             * @return this object.
144:             */
145:            public jsx3.gui.Form setKeyBinding(String strSequence) {
146:                ScriptBuffer script = new ScriptBuffer();
147:                script.appendCall(getContextPath() + "setKeyBinding",
148:                        strSequence);
149:                getScriptProxy().addScript(script);
150:                return this ;
151:            }
152:
153:            /**
154:             * Returns the background color of this control when it is disabled.
155:             * @param callback valid CSS property value, (i.e., red, #ff0000)
156:             */
157:            @SuppressWarnings("unchecked")
158:            public void getDisabledBackgroundColor(
159:                    org.directwebremoting.proxy.Callback<String> callback) {
160:                ScriptBuffer script = new ScriptBuffer();
161:                String callbackPrefix = "";
162:
163:                if (callback != null) {
164:                    callbackPrefix = "var reply = ";
165:                }
166:
167:                script.appendCall(callbackPrefix + getContextPath()
168:                        + "getDisabledBackgroundColor");
169:
170:                if (callback != null) {
171:                    String key = org.directwebremoting.extend.CallbackHelper
172:                            .saveCallback(callback, String.class);
173:                    script
174:                            .appendCall("__System.activateCallback", key,
175:                                    "reply");
176:                }
177:
178:                getScriptProxy().addScript(script);
179:            }
180:
181:            /**
182:             * Sets the background color of this form control when it is disabled.
183:             * @param strColor valid CSS property value, (i.e., red, #ff0000)
184:             * @return this object.
185:             */
186:            public jsx3.gui.Form setDisabledBackgroundColor(String strColor) {
187:                ScriptBuffer script = new ScriptBuffer();
188:                script.appendCall(getContextPath()
189:                        + "setDisabledBackgroundColor", strColor);
190:                getScriptProxy().addScript(script);
191:                return this ;
192:            }
193:
194:            /**
195:             * Returns the font color to use when this control is disabled.
196:             * @param callback valid CSS property value, (i.e., red, #ff0000)
197:             */
198:            @SuppressWarnings("unchecked")
199:            public void getDisabledColor(
200:                    org.directwebremoting.proxy.Callback<String> callback) {
201:                ScriptBuffer script = new ScriptBuffer();
202:                String callbackPrefix = "";
203:
204:                if (callback != null) {
205:                    callbackPrefix = "var reply = ";
206:                }
207:
208:                script.appendCall(callbackPrefix + getContextPath()
209:                        + "getDisabledColor");
210:
211:                if (callback != null) {
212:                    String key = org.directwebremoting.extend.CallbackHelper
213:                            .saveCallback(callback, String.class);
214:                    script
215:                            .appendCall("__System.activateCallback", key,
216:                                    "reply");
217:                }
218:
219:                getScriptProxy().addScript(script);
220:            }
221:
222:            /**
223:             * Sets the font color to use when this control is disabled.
224:             * @param strColor valid CSS property value, (i.e., red, #ff0000)
225:             * @return this object.
226:             */
227:            public jsx3.gui.Form setDisabledColor(String strColor) {
228:                ScriptBuffer script = new ScriptBuffer();
229:                script.appendCall(getContextPath() + "setDisabledColor",
230:                        strColor);
231:                getScriptProxy().addScript(script);
232:                return this ;
233:            }
234:
235:            /**
236:             * Returns the state for the form field control. If no enabled state is set, this method returns
237:            STATEENABLED.
238:             * @param callback <code>STATEDISABLED</code> or <code>STATEENABLED</code>.
239:             */
240:            @SuppressWarnings("unchecked")
241:            public void getEnabled(
242:                    org.directwebremoting.proxy.Callback<Integer> callback) {
243:                ScriptBuffer script = new ScriptBuffer();
244:                String callbackPrefix = "";
245:
246:                if (callback != null) {
247:                    callbackPrefix = "var reply = ";
248:                }
249:
250:                script.appendCall(callbackPrefix + getContextPath()
251:                        + "getEnabled");
252:
253:                if (callback != null) {
254:                    String key = org.directwebremoting.extend.CallbackHelper
255:                            .saveCallback(callback, Integer.class);
256:                    script
257:                            .appendCall("__System.activateCallback", key,
258:                                    "reply");
259:                }
260:
261:                getScriptProxy().addScript(script);
262:            }
263:
264:            /**
265:             * Returns the value of this control.
266:             */
267:            @SuppressWarnings("unchecked")
268:            public void getValue(
269:                    org.directwebremoting.proxy.Callback<Integer> callback) {
270:                ScriptBuffer script = new ScriptBuffer();
271:                String callbackPrefix = "";
272:
273:                if (callback != null) {
274:                    callbackPrefix = "var reply = ";
275:                }
276:
277:                script.appendCall(callbackPrefix + getContextPath()
278:                        + "getValue");
279:
280:                if (callback != null) {
281:                    String key = org.directwebremoting.extend.CallbackHelper
282:                            .saveCallback(callback, Integer.class);
283:                    script
284:                            .appendCall("__System.activateCallback", key,
285:                                    "reply");
286:                }
287:
288:                getScriptProxy().addScript(script);
289:            }
290:
291:            /**
292:             * Sets the value of this control.
293:             * @param vntValue string/int value for the component
294:             * @return this object.
295:             */
296:            public jsx3.gui.Form setValue(String vntValue) {
297:                ScriptBuffer script = new ScriptBuffer();
298:                script.appendCall(getContextPath() + "setValue", vntValue);
299:                getScriptProxy().addScript(script);
300:                return this ;
301:            }
302:
303:            /**
304:             * Sets the value of this control.
305:             * @param vntValue string/int value for the component
306:             * @return this object.
307:             */
308:            public jsx3.gui.Form setValue(Integer vntValue) {
309:                ScriptBuffer script = new ScriptBuffer();
310:                script.appendCall(getContextPath() + "setValue", vntValue);
311:                getScriptProxy().addScript(script);
312:                return this ;
313:            }
314:
315:            /**
316:             * Sets whether this control is enabled. Disabled controls do not respond to user interaction.
317:             * @param intEnabled <code>STATEDISABLED</code> or <code>STATEENABLED</code>. <code>null</code> is
318:            equivalent to <code>STATEENABLED</code>.
319:             * @param bRepaint if <code>true</code> this control is immediately repainted to reflect the new setting.
320:             */
321:            public void setEnabled(int intEnabled, boolean bRepaint) {
322:                ScriptBuffer script = new ScriptBuffer();
323:                script.appendCall(getContextPath() + "setEnabled", intEnabled,
324:                        bRepaint);
325:                getScriptProxy().addScript(script);
326:            }
327:
328:            /**
329:             * Returns whether or not this control is required. If the required property has never been set, this method returns
330:            OPTIONAL.
331:             * @param callback <code>REQUIRED</code> or <code>OPTIONAL</code>.
332:             */
333:            @SuppressWarnings("unchecked")
334:            public void getRequired(
335:                    org.directwebremoting.proxy.Callback<Integer> callback) {
336:                ScriptBuffer script = new ScriptBuffer();
337:                String callbackPrefix = "";
338:
339:                if (callback != null) {
340:                    callbackPrefix = "var reply = ";
341:                }
342:
343:                script.appendCall(callbackPrefix + getContextPath()
344:                        + "getRequired");
345:
346:                if (callback != null) {
347:                    String key = org.directwebremoting.extend.CallbackHelper
348:                            .saveCallback(callback, Integer.class);
349:                    script
350:                            .appendCall("__System.activateCallback", key,
351:                                    "reply");
352:                }
353:
354:                getScriptProxy().addScript(script);
355:            }
356:
357:            /**
358:             * Sets whether or not this control is required.
359:             * @param required {int} <code>REQUIRED</code> or <code>OPTIONAL</code>.
360:             * @return this object.
361:             */
362:            public jsx3.gui.Form setRequired(int required) {
363:                ScriptBuffer script = new ScriptBuffer();
364:                script.appendCall(getContextPath() + "setRequired", required);
365:                getScriptProxy().addScript(script);
366:                return this ;
367:            }
368:
369:            /**
370:             * Returns the validation state of this control. If the validationState property has never been set, this method returns
371:            STATEVALID.
372:             * @param callback <code>STATEINVALID</code> or <code>STATEVALID</code>.
373:             */
374:            @SuppressWarnings("unchecked")
375:            public void getValidationState(
376:                    org.directwebremoting.proxy.Callback<Integer> callback) {
377:                ScriptBuffer script = new ScriptBuffer();
378:                String callbackPrefix = "";
379:
380:                if (callback != null) {
381:                    callbackPrefix = "var reply = ";
382:                }
383:
384:                script.appendCall(callbackPrefix + getContextPath()
385:                        + "getValidationState");
386:
387:                if (callback != null) {
388:                    String key = org.directwebremoting.extend.CallbackHelper
389:                            .saveCallback(callback, Integer.class);
390:                    script
391:                            .appendCall("__System.activateCallback", key,
392:                                    "reply");
393:                }
394:
395:                getScriptProxy().addScript(script);
396:            }
397:
398:            /**
399:             * Sets the validation state of this control. The validation state of a control is not serialized.
400:             * @param intState <code>STATEINVALID</code> or <code>STATEVALID</code>.
401:             * @return this object.
402:             */
403:            public jsx3.gui.Form setValidationState(int intState) {
404:                ScriptBuffer script = new ScriptBuffer();
405:                script.appendCall(getContextPath() + "setValidationState",
406:                        intState);
407:                getScriptProxy().addScript(script);
408:                return this ;
409:            }
410:
411:            /**
412:             * Abstract method that must be implemented by any class that implements the Form interface.
413:             * @param callback <code>STATEINVALID</code> or <code>STATEVALID</code>.
414:             */
415:            @SuppressWarnings("unchecked")
416:            public void doValidate(
417:                    org.directwebremoting.proxy.Callback<Integer> callback) {
418:                ScriptBuffer script = new ScriptBuffer();
419:                String callbackPrefix = "";
420:
421:                if (callback != null) {
422:                    callbackPrefix = "var reply = ";
423:                }
424:
425:                script.appendCall(callbackPrefix + getContextPath()
426:                        + "doValidate");
427:
428:                if (callback != null) {
429:                    String key = org.directwebremoting.extend.CallbackHelper
430:                            .saveCallback(callback, Integer.class);
431:                    script
432:                            .appendCall("__System.activateCallback", key,
433:                                    "reply");
434:                }
435:
436:                getScriptProxy().addScript(script);
437:            }
438:
439:            /**
440:             * Resets the validation state of this control.
441:             * @return this object.
442:             */
443:            @SuppressWarnings("unchecked")
444:            public jsx3.gui.Form doReset() {
445:                String extension = "doReset().";
446:                try {
447:                    java.lang.reflect.Constructor<jsx3.gui.Form> ctor = jsx3.gui.Form.class
448:                            .getConstructor(Context.class, String.class,
449:                                    ScriptProxy.class);
450:                    return ctor.newInstance(this , extension, getScriptProxy());
451:                } catch (Exception ex) {
452:                    throw new IllegalArgumentException("Unsupported type: "
453:                            + jsx3.gui.Form.class.getName());
454:                }
455:            }
456:
457:            /**
458:             * Resets the validation state of this control.
459:             * @param returnType The expected return type
460:             * @return this object.
461:             */
462:            @SuppressWarnings("unchecked")
463:            public <T> T doReset(Class<T> returnType) {
464:                String extension = "doReset().";
465:                try {
466:                    java.lang.reflect.Constructor<T> ctor = returnType
467:                            .getConstructor(Context.class, String.class,
468:                                    ScriptProxy.class);
469:                    return ctor.newInstance(this , extension, getScriptProxy());
470:                } catch (Exception ex) {
471:                    throw new IllegalArgumentException(
472:                            "Unsupported return type: " + returnType.getName());
473:                }
474:            }
475:
476:            /**
477:             * Traverses the DOM branch starting at objJSXContainer and calls doValidate() on all nodes
478:            of type jsx3.gui.Form. A custom function handler, objHandler, can be passed that will
479:            be called once for each encountered form control.
480:             * @param objJSXContainer JSX GUI object containing all form fields that need to be validated (recursive validation will start with this item and be applied to all descendants, not just direct children)
481:             * @param objHandler a JavaScript function (as object). This function will be passed two parameters: the object reference to the JSX Form object (textbox, selectbox, checkbox, etc) being validated as well as a constant denoting whether or not it validated (0 or 1)&#8212;1 meaning true
482:             * @param callback <code>STATEINVALID</code> or <code>STATEVALID</code>.
483:             */
484:            @SuppressWarnings("unchecked")
485:            public void validate(jsx3.app.Model objJSXContainer,
486:                    org.directwebremoting.proxy.CodeBlock objHandler,
487:                    org.directwebremoting.proxy.Callback<Integer> callback) {
488:                ScriptBuffer script = new ScriptBuffer();
489:                String callbackPrefix = "";
490:
491:                if (callback != null) {
492:                    callbackPrefix = "var reply = ";
493:                }
494:
495:                script.appendCall(callbackPrefix + getContextPath()
496:                        + "validate", objJSXContainer, objHandler);
497:
498:                if (callback != null) {
499:                    String key = org.directwebremoting.extend.CallbackHelper
500:                            .saveCallback(callback, Integer.class);
501:                    script
502:                            .appendCall("__System.activateCallback", key,
503:                                    "reply");
504:                }
505:
506:                getScriptProxy().addScript(script);
507:            }
508:
509:            /**
510:             * Traverses the DOM branch starting at objJSXContainer and calls doReset() on all nodes
511:            of type jsx3.gui.Form.
512:             * @param objJSXContainer JSX GUI object containing all form fields that need to be reset (the 'reset' process will start with this item and be applied to all descendants, not just direct children)
513:             */
514:            public void reset(jsx3.app.Model objJSXContainer) {
515:                ScriptBuffer script = new ScriptBuffer();
516:                script.appendCall(getContextPath() + "reset", objJSXContainer);
517:                getScriptProxy().addScript(script);
518:            }
519:
520:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.