01: /*
02: * GWT-Ext Widget Library
03: * Copyright(c) 2007-2008, GWT-Ext.
04: * licensing@gwt-ext.com
05: *
06: * http://www.gwt-ext.com/license
07: */
08: package com.gwtext.sample.showcase2.client.form;
09:
10: import com.gwtext.client.widgets.Button;
11: import com.gwtext.client.widgets.Panel;
12: import com.gwtext.client.widgets.form.FieldSet;
13: import com.gwtext.client.widgets.form.FormPanel;
14: import com.gwtext.client.widgets.form.TextField;
15: import com.gwtext.client.widgets.form.VType;
16: import com.gwtext.sample.showcase2.client.ShowcasePanel;
17:
18: public class FieldSetsSample extends ShowcasePanel {
19:
20: public String getSourceUrl() {
21: return "source/form/FieldSetsSample.java.html";
22: }
23:
24: public Panel getViewPanel() {
25: if (panel == null) {
26: panel = new Panel();
27:
28: //create the form
29: FormPanel formPanel = new FormPanel();
30: formPanel.setTitle("Simple Form with FieldSets");
31: formPanel.setFrame(true);
32: formPanel.setPaddings(5, 5, 5, 0);
33: formPanel.setWidth(350);
34: formPanel.setLabelWidth(75);
35: formPanel.setUrl("save-form.php");
36:
37: //create first collapsible fieldset with checkbox
38: FieldSet userFS = new FieldSet();
39: userFS.setCheckboxToggle(true);
40: userFS.setFrame(true);
41: userFS.setTitle("User Information");
42: userFS.setCollapsed(true);
43:
44: //add fields to the User FieldSet
45: TextField first = new TextField("First Name", "first", 210);
46: first.setAllowBlank(false);
47: userFS.add(first);
48:
49: TextField last = new TextField("Last Name", "last", 210);
50: userFS.add(last);
51:
52: TextField company = new TextField("Company", "company, 210");
53: userFS.add(company);
54:
55: TextField email = new TextField("Email", "email", 210);
56: email.setVtype(VType.EMAIL);
57: userFS.add(email);
58:
59: //create another FieldSet
60: FieldSet detailsFS = new FieldSet("Phone Number");
61: detailsFS.setCollapsible(true);
62: detailsFS.setAutoHeight(true);
63:
64: //add fields to Details FieldSet
65: TextField home = new TextField("Home", "home", 210);
66: home.setValue("(888) 555-1212");
67: detailsFS.add(home);
68:
69: TextField business = new TextField("Business", "business",
70: 210);
71: detailsFS.add(business);
72:
73: TextField mobile = new TextField("Mobile", "mobile", 210);
74: detailsFS.add(mobile);
75:
76: TextField fax = new TextField("Fax", "fax", 210);
77: detailsFS.add(fax);
78:
79: formPanel.add(userFS);
80: formPanel.add(detailsFS);
81:
82: formPanel.addButton(new Button("Save"));
83: formPanel.addButton(new Button("Cancel"));
84:
85: panel.add(formPanel);
86: }
87: return panel;
88: }
89:
90: public String getIntro() {
91: return "<p>This example demonstrates the use of FieldSet's in Forms. FieldSets are a subclass of Panel and can be "
92: + "added to the FormPaenl just like other Components. FieldSet's in turn can contain Form fields.</p>"
93: + "<p>The FieldSet at the top is collapsible and has a toggle checkbox to expand / collapse the FieldSet.</p>"
94: + "<p>The FieldSet at the bottom contains other form Fields</p>";
95: }
96: }
|