|
@@ -5,6 +5,7 @@ |
5 |
5 |
|
import com.google.gwt.core.client.*; |
6 |
6 |
|
import com.google.gwt.event.dom.client.*; |
7 |
7 |
|
import com.google.gwt.user.client.ui.*; |
|
8 |
+ |
import com.temp.client.foundation.util.UtilsGwt; |
8 |
9 |
|
import com.temp.client.foundation.widget.*; |
9 |
10 |
|
import com.temp.client.foundation.widget.input.*; |
10 |
11 |
|
import com.temp.shared.externalization.*; |
|
@@ -23,6 +24,8 @@ |
23 |
24 |
|
"Required", "* means Required", // |
24 |
25 |
|
"NotIdentifier", "Unacceptable entry: {why}", // |
25 |
26 |
|
"Fred_BadCharacter", "'{character}' not allowed", // |
|
27 |
+ |
"Public_field-label", "Public", // |
|
28 |
+ |
"Private_field-label", "Private", // |
26 |
29 |
|
"SetValue", "Set Value", // |
27 |
30 |
|
}; |
28 |
31 |
|
|
|
@@ -49,10 +52,15 @@ |
49 |
52 |
|
Red, Green, Blue |
50 |
53 |
|
} |
51 |
54 |
|
|
52 |
|
- |
// Pretend "Injected" |
|
55 |
+ |
// Pretend "Injected" by the "ui.xml" file |
53 |
56 |
|
private TextInputField tif = new TextInputField().name( "Fred" ).helpLink( "XX#Fred" ).required().maxLength( 9 ).extendedLabel().example().errorLabel(); |
54 |
|
- |
private OptionBoxInputField<Options> obif = new OptionBoxInputField<Options>().name( "Wilma" ).helpLink( "XX#YY" ).required().labelPosition( LabelPosition.Top ).errorLabel(); |
55 |
|
- |
private CheckBoxInputField cbif = new CheckBoxInputField().name( "Pebbles" ).helpLink( "XX#YY" ).labelPosition( LabelPosition.Right ); |
|
57 |
+ |
private OptionBoxInputField<Options> obif = new OptionBoxInputField<Options>().name("Wilma").helpLink("XX#YY").required().labelPosition(LabelPosition.Top).errorLabel(); |
|
58 |
+ |
private CheckBoxInputField cbif = new CheckBoxInputField().name("Pebbles").helpLink("XX#YY").labelPosition(LabelPosition.Right); |
|
59 |
+ |
private RadioButtonInputField rbif1 = new RadioButtonInputField().name("Public").group("Visibility").helpLink( "XX#YY" ).labelPosition( LabelPosition.Right ); |
|
60 |
+ |
private RadioButtonInputField rbif2 = new RadioButtonInputField().name("Private").group("Visibility").helpLink("XX#YY").labelPosition(LabelPosition.Right); |
|
61 |
+ |
|
|
62 |
+ |
VerticalPanel radioButtonContainer = UtilsGwt.add( UtilsGwt.add( UtilsGwt.vertical("radioButtonContainer"), rbif1 ), rbif2 ); |
|
63 |
+ |
|
56 |
64 |
|
private NamedTextButton buttonSetValue = new NamedTextButton( "SetValue", new ClickHandler() |
57 |
65 |
|
{ |
58 |
66 |
|
public void onClick( ClickEvent event ) |
|
@@ -71,16 +79,26 @@ |
71 |
79 |
|
} ); |
72 |
80 |
|
private Button buttonValidate = new Button( "Validate" ); |
73 |
81 |
|
|
|
82 |
+ |
// Fake "View" |
74 |
83 |
|
public void onModuleLoad() |
75 |
84 |
|
{ |
|
85 |
+ |
// Initialize the "View" Resolver |
76 |
86 |
|
E13nResolver viewResolver = new OptionallyPrefixingE13nResolver( "BusinessUnitManager", globalResolver ); |
77 |
87 |
|
|
|
88 |
+ |
// Create Composite(s) |
|
89 |
+ |
RadioButtonGroupInputField rbgif = new RadioButtonGroupInputField(radioButtonContainer, rbif1, rbif2); |
|
90 |
+ |
|
|
91 |
+ |
// Create FormEngine |
78 |
92 |
|
FormEngine fe = new FormEngine( "Family" ); |
79 |
93 |
|
|
|
94 |
+ |
// Add the Input Fields to the FormEngine |
80 |
95 |
|
fe.add( tif.add( IdentifierValueValidator.INSTANCE ), // |
81 |
96 |
|
obif.addNullOptional().addOptions( Options.values() ), // |
82 |
|
- |
cbif ); |
|
97 |
+ |
cbif, // |
|
98 |
+ |
rbgif ); |
|
99 |
+ |
// Add the Managed Buttons |
83 |
100 |
|
fe.addManaged( buttonSetValue, buttonSetValueAsUser ); |
|
101 |
+ |
// Add the Submit Button and its Callback |
84 |
102 |
|
fe.setSubmit( buttonValidate, new FormEngine.Callback() |
85 |
103 |
|
{ |
86 |
104 |
|
@Override |
|
@@ -89,13 +107,21 @@ |
89 |
107 |
|
System.out.println( "Form '"+name+"' says OK to Submit!" ); |
90 |
108 |
|
} |
91 |
109 |
|
} ); |
|
110 |
+ |
// Initialize the FormEngine (which will in turn initialize all the Input Fields) |
92 |
111 |
|
fe.init( viewResolver ); |
|
112 |
+ |
// Finally apply IDs to "everything" named |
93 |
113 |
|
fe.addNamedWidgetsTo( new NameToID() ).applyIDs(); |
94 |
114 |
|
|
|
115 |
+ |
|
|
116 |
+ |
// Below here is what would normally be handled by the "ui.xml" file. |
|
117 |
+ |
|
95 |
118 |
|
VerticalPanel zVPanel = new VerticalPanel(); |
96 |
119 |
|
zVPanel.add( new HTML( " " ) ); |
97 |
120 |
|
zVPanel.add( horizontalWithSpacers( tif, new HTML( " " ), obif, new HTML( " " ), cbif ) ); |
98 |
121 |
|
zVPanel.add( new HTML( " " ) ); |
|
122 |
+ |
zVPanel.add(rbif1); |
|
123 |
+ |
zVPanel.add(rbif2); |
|
124 |
+ |
zVPanel.add( new HTML( " " ) ); |
99 |
125 |
|
zVPanel.add( horizontalWithSpacers( buttonSetValue, buttonSetValueAsUser, buttonValidate ) ); |
100 |
126 |
|
zVPanel.add( new HTML( " " ) ); |
101 |
127 |
|
zVPanel.add( new HTML( " " ) ); |
|
@@ -109,6 +135,7 @@ |
109 |
135 |
|
complete( tif ); |
110 |
136 |
|
complete( obif ); |
111 |
137 |
|
complete( cbif ); |
|
138 |
+ |
complete( rbgif ); |
112 |
139 |
|
} |
113 |
140 |
|
|
114 |
141 |
|
private HorizontalPanel createFormInteractionButtons( final FormEngine fe ) |
|
@@ -178,7 +205,7 @@ |
178 |
205 |
|
public void changed( InputField<T> field ) |
179 |
206 |
|
{ |
180 |
207 |
|
T value = field.getCurrentValue(); |
181 |
|
- |
System.out.println( "Change (" + field.getName() + "): " + field.isChanged() + " '" + value + "' | " + field.getValidator().getErrorData() ); |
|
208 |
+ |
System.out.println( "Change (" + field.getName() + "): " + field.isChanged() + " '" + value + "' | " + field.getErrorData() ); |
182 |
209 |
|
if ( "OK".equals( value ) ) |
183 |
210 |
|
{ |
184 |
211 |
|
field.setCurrentValue( value ); |