Source Code Cross Referenced for TextField.java in  » Ajax » gwtext-2.01 » com » gwtext » client » widgets » 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 » Ajax » gwtext 2.01 » com.gwtext.client.widgets.form 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * GWT-Ext Widget Library
003:         * Copyright(c) 2007-2008, GWT-Ext.
004:         * licensing@gwt-ext.com
005:         * 
006:         * http://www.gwt-ext.com/license
007:         */
008:
009:        package com.gwtext.client.widgets.form;
010:
011:        import com.google.gwt.core.client.JavaScriptObject;
012:        import com.gwtext.client.util.JavaScriptObjectHelper;
013:        import com.gwtext.client.widgets.form.event.TextFieldListener;
014:
015:        /**
016:         * Basic text field.
017:         */
018:        public class TextField extends Field {
019:
020:            private static JavaScriptObject configPrototype;
021:
022:            static {
023:                init();
024:            }
025:
026:            private static native void init()/*-{
027:            		var c = new $wnd.Ext.form.TextField();
028:            		@com.gwtext.client.widgets.form.TextField::configPrototype = c.initialConfig;
029:            	}-*/;
030:
031:            protected JavaScriptObject getConfigPrototype() {
032:                return configPrototype;
033:            }
034:
035:            public String getXType() {
036:                return "textfield";
037:            }
038:
039:            /**
040:             * Create a new TextField.
041:             */
042:            public TextField() {
043:            }
044:
045:            /**
046:             * Create a new TextField.
047:             *
048:             * @param fieldLabel the field label
049:             */
050:            public TextField(String fieldLabel) {
051:                super (fieldLabel);
052:            }
053:
054:            /**
055:             * Create a new TextField.
056:             *
057:             * @param fieldLabel the field label
058:             * @param name the field name
059:             */
060:            public TextField(String fieldLabel, String name) {
061:                super (fieldLabel, name);
062:            }
063:
064:            /**
065:             * Create a new TextField.
066:             *
067:             * @param fieldLabel the field label
068:             * @param name the field name
069:             * @param width the field width
070:             */
071:            public TextField(String fieldLabel, String name, int width) {
072:                super (fieldLabel, name, width);
073:            }
074:
075:            /**
076:             * Create a new TextField.
077:             *
078:             * @param fieldLabel the field label
079:             * @param name the field name
080:             * @param width the field width
081:             * @param value the field value
082:             */
083:            public TextField(String fieldLabel, String name, int width,
084:                    String value) {
085:                super (fieldLabel, name, width);
086:                setValue(value);
087:            }
088:
089:            public TextField(JavaScriptObject jsObj) {
090:                super (jsObj);
091:            }
092:
093:            protected native JavaScriptObject create(JavaScriptObject jsObj) /*-{
094:                   return new $wnd.Ext.form.TextField(jsObj);
095:               }-*/;
096:
097:            /**
098:             * Add a TextField listener.
099:             *
100:             * @param listener the listener
101:             */
102:            public native void addListener(TextFieldListener listener) /*-{
103:                   this.@com.gwtext.client.widgets.form.Field::addListener(Lcom/gwtext/client/widgets/form/event/FieldListener;)(listener);
104:                   var fieldJ = this;
105:
106:                   this.@com.gwtext.client.widgets.Component::addListener(Ljava/lang/String;Lcom/google/gwt/core/client/JavaScriptObject;)('autosize',
107:                           function(fld, width) {
108:                               listener.@com.gwtext.client.widgets.form.event.TextFieldListener::onAutoSize(Lcom/gwtext/client/widgets/form/Field;I)(fieldJ, width);
109:                           }
110:                   );
111:               }-*/;
112:
113:            /**
114:             * Automatically grows the field to accomodate the width of the text up to the maximum field width allowed. This only takes effect if grow = true,
115:             * and fires the autosize event.
116:             */
117:            public native void autoSize() /*-{
118:                   var field = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
119:                   field.autoSize();
120:               }-*/;
121:
122:            /**
123:             * Selects text in this field.
124:             */
125:            public native void selectText() /*-{
126:                   var field = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
127:                   field.selectText();
128:               }-*/;
129:
130:            /**
131:             * Selects text in this field.
132:             *
133:             * @param start the index where the selection should start 
134:             * @param end the index where the selection should end
135:             */
136:            public native void selectText(int start, int end) /*-{
137:                   var field = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
138:                   field.selectText(start, end);
139:               }-*/;
140:
141:            /**
142:             * Validates a value according to the field's validation rules and marks the field as invalid if the validation fails.
143:             * 
144:             * @param value the value to valdiate
145:             * @return true if valid
146:             */
147:            public native boolean validateValue(String value) /*-{
148:                   var field = this.@com.gwtext.client.widgets.Component::getOrCreateJsObj()();
149:                   return field.validateValue(value);
150:               }-*/;
151:
152:            /**
153:             * Returns the value of the text field.
154:             * 
155:             * @return the text field value
156:             */
157:            public String getText() {
158:                return getValueAsString();
159:            }
160:
161:            // --- config properties ---
162:
163:            /**
164:             * False to validate that the value length > 0 (defaults to true).
165:             *
166:             * @param allowBlank false to disallow blank
167:             */
168:            public void setAllowBlank(boolean allowBlank) {
169:                setAttribute("allowBlank", allowBlank, true, true);
170:            }
171:
172:            /**
173:             * Error text to display if the allow blank validation fails (defaults to "This field is required").
174:             *
175:             * @param blankText error message for blank field
176:             */
177:            public void setBlankText(String blankText) {
178:                setAttribute("blankText", blankText, true, true);
179:            }
180:
181:            /**
182:             * True to disable input keystroke filtering (defaults to false).
183:             *
184:             * @param disableKeyFilter true to disable
185:             * @throws IllegalStateException this property cannot be changed after the Component has been rendered
186:             */
187:            public void setDisableKeyFilter(boolean disableKeyFilter)
188:                    throws IllegalStateException {
189:                setAttribute("disableKeyFilter", disableKeyFilter, true);
190:            }
191:
192:            /**
193:             * The CSS class to apply to an empty field to style the emptyText (defaults to 'x-form-empty-field'). This class is
194:             * automatically added and removed as needed depending on the current field value.
195:             *
196:             * @param emptyClass the empty field CSS class
197:             * @throws IllegalStateException this property cannot be changed after the Component has been rendered
198:             */
199:            public void setEmptyClass(String emptyClass)
200:                    throws IllegalStateException {
201:                setAttribute("emptyClass", emptyClass, true);
202:            }
203:
204:            /**
205:             * The default text to display in an empty field (defaults to null).
206:             *
207:             * @param emptyText the empty field text
208:             */
209:            public void setEmptyText(String emptyText) {
210:                setAttribute("emptyText", emptyText, true, true);
211:            }
212:
213:            /**
214:             * True if this field should automatically grow and shrink to its content.
215:             *
216:             * @param grow true to allow grow
217:             * @throws IllegalStateException this property cannot be changed after the Component has been rendered
218:             */
219:            public void setGrow(boolean grow) throws IllegalStateException {
220:                setAttribute("grow", grow, true);
221:            }
222:
223:            /**
224:             *  The maximum width to allow when grow = true (defaults to 800).
225:             *
226:             * @param growMax the max width
227:             * @throws IllegalStateException this property cannot be changed after the Component has been rendered
228:             */
229:            public void setGrowMax(int growMax) throws IllegalStateException {
230:                setAttribute("growMax", growMax, true);
231:            }
232:
233:            /**
234:             * The minimum width to allow when grow = true (defaults to 30).
235:             *
236:             * @param growMin the minimum width
237:             * @throws IllegalStateException this property cannot be changed after the Component has been rendered
238:             */
239:            public void setGrowMin(int growMin) throws IllegalStateException {
240:                setAttribute("growMin", growMin, true);
241:            }
242:
243:            /**
244:             * An input mask regular expression that will be used to filter keystrokes that
245:             * don't match (defaults to null).
246:             *
247:             * <br><br>
248:             * <b>Note:</b> This property cannot be changed after the Component has been rendered.
249:             *
250:             * @param maskRe the mask regular expression
251:             */
252:            public native void setMaskRe(String maskRe) /*-{
253:                   var config = this.@com.gwtext.client.widgets.Component::config;
254:                   config['maskRe'] = new $wnd.RegExp(maskRe);
255:               }-*/;
256:
257:            public void setMaxLength(int maxLength) {
258:                setAttribute("maxLength", maxLength, true, true);
259:            }
260:
261:            /**
262:             * Error text to display if the maximum length validation fails.
263:             * (defaults to "The maximum length for this field is {maxLength}")
264:             *
265:             * @param maxLengthText the max lenght error text
266:             */
267:            public void setMaxLengthText(String maxLengthText) {
268:                setAttribute("maxLengthText", maxLengthText, true, true);
269:            }
270:
271:            /**
272:             * Minimum input field length required (defaults to 0).
273:             *
274:             * @param minLength the min length
275:             */
276:            public void setMinLength(int minLength) {
277:                setAttribute("minLength", minLength, true, true);
278:            }
279:
280:            /**
281:             * Error text to display if the minimum length validation fails. (defaults to "The minimum length for this field is {minLength}")
282:             *
283:             * @param minLengthText the min length error text
284:             */
285:            public void setMinLengthText(String minLengthText) {
286:                setAttribute("minLengthText", minLengthText, true, true);
287:            }
288:
289:            /**
290:             * Set true if field is a password field.
291:             *
292:             * @param password true if passowrd field
293:             * @throws IllegalStateException this property cannot be changed after the Component has been rendered
294:             */
295:            public void setPassword(boolean password)
296:                    throws IllegalStateException {
297:                if (password)
298:                    setInputType("password");
299:            }
300:
301:            /**
302:             * A Regular Expressionto be tested against the field value during validation (defaults to null).
303:             * If available, this regex will be evaluated only after the basic validators all return true, and will be passed
304:             * the current field value. If the test fails, the field will be marked invalid using regexText.
305:             *
306:             *
307:             * @param regex the regular expression
308:             */
309:            public void setRegex(String regex) {
310:                setRegex(isCreated() ? getJsObj() : config, regex);
311:            }
312:
313:            private native void setRegex(JavaScriptObject config, String regex) /*-{
314:                   config['regex'] = new $wnd.RegExp(regex);
315:               }-*/;
316:
317:            /**
318:             * The error text to display if regex is used and the test fails during validation (defaults to "").
319:             *
320:             * <br><br>
321:             * <b>Note:</b> This property cannot be changed after the Component has been rendered.
322:             *
323:             * @param regexText the regexp text
324:             */
325:            public void setRegexText(String regexText) {
326:                setAttribute("regexText", regexText, true, true);
327:            }
328:
329:            /**
330:             * True to automatically select any existing field text when the field receives input focus (defaults to false).
331:             *
332:             * @param selectOnFocus true to select text on focus
333:             * @throws IllegalStateException this property cannot be changed after the Component has been rendered
334:             */
335:            public void setSelectOnFocus(boolean selectOnFocus)
336:                    throws IllegalStateException {
337:                setAttribute("selectOnFocus", selectOnFocus, true);
338:            }
339:
340:            /**
341:             * Set a custom Validator for the Field.
342:             *
343:             *
344:             * @param validator the field validator
345:             */
346:            public void setValidator(Validator validator) {
347:                setValidator(config, validator);
348:            }
349:
350:            private static String doValidate(Validator validator, String value) {
351:                try {
352:                    return validator.validate(value) ? "true-val" : "false-val";
353:                } catch (ValidationException e) {
354:                    return e.getMessage();
355:                }
356:            }
357:
358:            private native void setValidator(JavaScriptObject config,
359:                    Validator validator) /*-{
360:                   config['validator'] = function(value) {
361:                       var val = @com.gwtext.client.widgets.form.TextField::doValidate(Lcom/gwtext/client/widgets/form/Validator;Ljava/lang/String;)(validator, value);
362:                       if(val === "true-val") {
363:                           return true;
364:                       } else if ( val === "false-val") {
365:                           return false;
366:                       } else {
367:                           return val;
368:                       }
369:                   }
370:               }-*/;
371:
372:            //http://extjs.com/forum/showthread.php?t=5717&highlight=vtype
373:            /**
374:             * A validation type name as defined in {@link VType} (defaults to null).
375:             *
376:             * @param vtype the validation type
377:             */
378:            public void setVtype(VType vtype) {
379:                setAttribute("vtype", vtype.getVType(), true);
380:            }
381:
382:            /**
383:             * The validation type text if the validation specified by {@link #setVtype(VType)} fails.
384:             *
385:             * @param vtypeText the vtype
386:             */
387:            public void setVtypeText(String vtypeText) {
388:                setAttribute("vtypeText", vtypeText, true);
389:            }
390:
391:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.