Source Code Cross Referenced for XmlFormSample.java in  » Ajax » gwtext-2.01 » com » gwtext » sample » showcase2 » client » 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.sample.showcase2.client.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:        package com.gwtext.sample.showcase2.client.form;
009:
010:        import com.gwtext.client.core.Connection;
011:        import com.gwtext.client.core.EventObject;
012:        import com.gwtext.client.core.Position;
013:        import com.gwtext.client.data.*;
014:        import com.gwtext.client.widgets.Button;
015:        import com.gwtext.client.widgets.Panel;
016:        import com.gwtext.client.widgets.event.ButtonListenerAdapter;
017:        import com.gwtext.client.widgets.form.*;
018:        import com.gwtext.sample.showcase2.client.SampleData;
019:        import com.gwtext.sample.showcase2.client.ShowcasePanel;
020:
021:        public class XmlFormSample extends ShowcasePanel {
022:
023:            public String getSourceUrl() {
024:                return "source/form/XmlFormSample.java.html";
025:            }
026:
027:            public String getXmlDataUrl() {
028:                return "source/form/XmlFormSample.xml.html";
029:            }
030:
031:            public Panel getViewPanel() {
032:                if (panel == null) {
033:                    panel = new Panel();
034:
035:                    //setup form data reader
036:                    RecordDef recordDef = new RecordDef(new FieldDef[] {
037:                            new StringFieldDef("first", "name/first"),
038:                            new StringFieldDef("last", "name/last"),
039:                            new StringFieldDef("company"),
040:                            new StringFieldDef("email"),
041:                            new StringFieldDef("state"),
042:                            new DateFieldDef("dob", "dob", "m/d/Y") });
043:
044:                    final XmlReader reader = new XmlReader("contact", recordDef);
045:                    reader.setSuccess("@success");
046:
047:                    //setup error reader to process from submit response from server
048:                    RecordDef errorRecordDef = new RecordDef(
049:                            new FieldDef[] { new StringFieldDef("id"),
050:                                    new StringFieldDef("msg") });
051:
052:                    XmlReader errorReader = new XmlReader("field",
053:                            errorRecordDef);
054:                    errorReader.setSuccess("@success");
055:
056:                    final FormPanel formPanel = new FormPanel(Position.RIGHT);
057:                    formPanel.setFrame(true);
058:                    formPanel.setTitle("XML Form");
059:                    formPanel.setWidth(400);
060:                    formPanel.setLabelWidth(75);
061:                    //set reader and error reader
062:                    formPanel.setReader(reader);
063:                    formPanel.setErrorReader(errorReader);
064:
065:                    //add some fields
066:                    FieldSet fieldSet = new FieldSet("Contact Information");
067:                    fieldSet.add(new TextField("First Name", "first", 190));
068:                    fieldSet.add(new TextField("Last Name", "last", 190));
069:                    fieldSet.add(new TextField("Company", "company", 190));
070:
071:                    TextField email = new TextField("Email", "email", 190);
072:                    email.setVtype(VType.EMAIL);
073:                    fieldSet.add(email);
074:
075:                    //add a ComboBox field
076:                    Store store = new SimpleStore(new String[] { "abbr",
077:                            "state" }, SampleData.getStates());
078:                    store.load();
079:
080:                    ComboBox cb = new ComboBox();
081:                    cb.setFieldLabel("State");
082:                    cb.setHiddenName("state");
083:                    cb.setStore(store);
084:                    cb.setDisplayField("abbr");
085:                    cb.setTypeAhead(true);
086:                    cb.setMode(ComboBox.LOCAL);
087:                    cb.setTriggerAction(ComboBox.ALL);
088:                    cb.setEmptyText("Select a state...");
089:                    cb.setSelectOnFocus(true);
090:                    cb.setWidth(190);
091:                    fieldSet.add(cb);
092:
093:                    DateField dob = new DateField("Date of birth", "dob", 190);
094:                    dob.setAllowBlank(false);
095:                    fieldSet.add(dob);
096:
097:                    formPanel.add(fieldSet);
098:
099:                    final Button submitBtn = new Button("Submit",
100:                            new ButtonListenerAdapter() {
101:                                public void onClick(Button button, EventObject e) {
102:                                    formPanel.getForm().submit(
103:                                            "data/xml-errors.xml", null,
104:                                            Connection.GET, "Saving Data...",
105:                                            false);
106:                                }
107:                            });
108:
109:                    Button loadBtn = new Button("Load",
110:                            new ButtonListenerAdapter() {
111:                                public void onClick(Button button, EventObject e) {
112:                                    formPanel.getForm().load(
113:                                            "data/xml-form.xml", null,
114:                                            Connection.GET, "Loading...");
115:                                    submitBtn.enable();
116:                                }
117:                            });
118:
119:                    formPanel.addButton(loadBtn);
120:                    formPanel.addButton(submitBtn);
121:                    panel.add(formPanel);
122:                }
123:
124:                return panel;
125:            }
126:
127:            public String getIntro() {
128:                return "<b>Loading/Saving a Form using XML</b>"
129:                        + "<p>"
130:                        + "    This is a very simple example of using XML to load and submit Form data."
131:                        + "</p>"
132:                        + "<p>"
133:                        + "    Click \"Load\" to load the dummy XML data from the server using an XmlReader."
134:                        + "</p>"
135:                        + "<p>"
136:                        + "    After loading the form, you will be able to hit submit. The submit action will make a post to the server,"
137:                        + "    and the dummy XML file on the server with test server-side validation failure messages will be sent back."
138:                        + "    Those messages will be applied to the appropriate fields in the form."
139:                        + ""
140:                        + "</p>"
141:                        + "<p>"
142:                        + "    Note: The built-in JSON support does not require any special readers for mapping. However, If you don't like the Form's built-in JSON format, you could also use a JsonReader for reading data into a form."
143:                        + "</p>";
144:            }
145:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.