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.TabPanel;
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.client.widgets.layout.FormLayout;
17: import com.gwtext.sample.showcase2.client.ShowcasePanel;
18:
19: public class FormAsTabSample extends ShowcasePanel {
20:
21: public String getSourceUrl() {
22: return "source/form/FormAsTabSample.java.html";
23: }
24:
25: public Panel getViewPanel() {
26: if (panel == null) {
27: panel = new Panel();
28:
29: FormPanel formPanel = new FormPanel();
30: formPanel.setFrame(true);
31: formPanel.setLabelWidth(75);
32: formPanel.setBorder(false);
33: formPanel.setWidth(350);
34:
35: final TabPanel tabPanel = new TabPanel();
36: tabPanel.setActiveTab(0);
37:
38: Panel firstTab = new Panel();
39: firstTab.setTitle("Personal Details");
40: firstTab.setLayout(new FormLayout());
41: firstTab.setAutoHeight(true);
42: firstTab.setPaddings(10);
43:
44: TextField firstName = new TextField("First Name", "first",
45: 230);
46: firstName.setAllowBlank(false);
47: firstName.setValue("Steve");
48: firstTab.add(firstName);
49:
50: TextField lastName = new TextField("Last Name", "last", 230);
51: lastName.setValue("Rogge");
52: firstTab.add(lastName);
53:
54: TextField company = new TextField("Company", "company", 230);
55: firstTab.add(company);
56:
57: TextField email = new TextField("Email", "email", 230);
58: email.setVtype(VType.EMAIL);
59: firstTab.add(email);
60:
61: tabPanel.add(firstTab);
62:
63: Panel secondTab = new Panel();
64: secondTab.setTitle("Phone Numbers");
65: secondTab.setLayout(new FormLayout());
66: secondTab.setAutoHeight(true);
67: secondTab.setPaddings(10);
68:
69: secondTab.add(new TextField("Home", "home", 230,
70: "(888) 555-2222"));
71: secondTab.add(new TextField("Business", "business", 230));
72: secondTab.add(new TextField("Mobile", "mobile", 230));
73: secondTab.add(new TextField("Fax", "fax", 230));
74:
75: tabPanel.add(secondTab);
76:
77: Button save = new Button("Save");
78: Button cancel = new Button("Cancel");
79:
80: formPanel.addButton(save);
81: formPanel.addButton(cancel);
82:
83: formPanel.add(tabPanel);
84: panel.add(formPanel);
85: }
86:
87: return panel;
88: }
89:
90: public String getIntro() {
91: return "<b>Form as a TabPanel</b>"
92: + "<p>"
93: + "This example shows that a Form can be setup as a TabPanel with form fields on separate tabs."
94: + " An key feature of this is that when the form is submitted, the field values form all the tabs are posted."
95: + "</p>";
96: }
97: }
|