Subversion Repository Public Repository

litesoft

Diff Revisions 628 vs 629 for /trunk/GWT_Sandbox/FormEngine/src/org/litesoft/sampleapplication/sampleApplication/client/SampleApplication.java

Diff revisions: vs.
  @@ -4,55 +4,50 @@
4 4 import com.google.gwt.event.dom.client.*;
5 5 import com.google.gwt.user.client.ui.*;
6 6 import com.temp.client.foundation.widget.input.*;
7 - import com.temp.client.foundation.widget.input.fieldsupport.*;
8 - import com.temp.client.foundation.widget.input.support.*;
7 + import com.temp.shared.externalization.*;
8 + import com.temp.shared.utils.*;
9 9 import com.temp.shared.validators.*;
10 10
11 11 public class SampleApplication implements EntryPoint
12 12 {
13 13 public void onModuleLoad()
14 14 {
15 - Label fieldLabel = new Label( "Name:" );
16 - Label errorLabel = new Label( "Error" );
17 - HTML stateLabel = new HTML( " " );
18 - ActiveTextBox field = new ActiveTextBox();
15 + final TextInputField tif = (TextInputField) new TextInputField().maxLength( 9 ).required().extendedLabel().example().errorLabel().helpLink( "XX:YY" ).name( "Fred" );
19 16
20 - final InputWidgetValidator<String> validator = new InputWidgetValidator<String>( new TextBoxBaseValueAdapter( field ) );
21 - final InputWidgetChangeFilter<String> input = new InputWidgetChangeFilter<String>( validator );
17 + tif.add( IdentifierValueValidator.INSTANCE );
22 18
23 - input.addChangeHandler( new ChangeHandler()
19 + tif.init( new TemplateSourceE13nResolver( new TemplateSource()
24 20 {
25 - @Override
26 - public void onChange( ChangeEvent event )
21 + @Override public String get( String key )
27 22 {
28 - String value = input.getValue();
29 - System.out.println( "Change: " + input.isChanged() + " '" + value + "'" );
30 - if ( "OK".equals( value ) )
31 - {
32 - input.setValue( value );
33 - }
23 + System.out.println( "Template Get: " + key );
24 + return null;
34 25 }
35 - } );
36 26
37 - validator.addErrorStateChangeHandler( new ChangeHandler()
27 + @Override public String get( String key, String defaultValue )
28 + {
29 + return StringUtils.deNull( get( key ), defaultValue );
30 + }
31 + } ) );
32 +
33 + tif.add( new InputField.ChangeListener<String>()
38 34 {
39 - @Override
40 - public void onChange( ChangeEvent event )
35 + @Override public void changed( InputField<String> field )
41 36 {
42 - String value = input.getValue();
43 - System.out.println( "Valid: '" + value + "' | " + validator.getErrorData() );
37 + String value = field.getCurrentValue();
38 + System.out.println( "Change: " + field.isChanged() + " '" + value + "' | " + tif.getValidator().getErrorData());
39 + if ( "OK".equals( value ) )
40 + {
41 + field.setCurrentValue( value );
42 + }
44 43 }
45 44 } );
46 45
47 - validator.addValidators( RequiredValueValidator.INSTANCE, //
48 - new MaxLengthValueValidator( 9 ), //
49 - IdentifierValueValidator.INSTANCE );
50 -
51 46 Button buttonSetValue = new Button( "Set Value", new ClickHandler()
52 47 {
53 48 public void onClick( ClickEvent event )
54 49 {
55 - input.setValue( input.getValue() );
50 + tif.setCurrentValue( tif.getCurrentValue() );
56 51 System.out.println( "Set Value!" );
57 52 }
58 53 } );
  @@ -60,18 +55,14 @@
60 55 {
61 56 public void onClick( ClickEvent event )
62 57 {
63 - input.setValueAsUser( input.getValue() + "!" );
58 + tif.getInput().setValueAsUser( tif.getCurrentValue() + "!" );
64 59 System.out.println( "User Set Value!" );
65 60 }
66 61 } );
67 62
68 - VerticalPanel zFieldErrorPanel = new VerticalPanel();
69 - zFieldErrorPanel.add( field );
70 - zFieldErrorPanel.add( errorLabel );
71 -
72 63 VerticalPanel zVPanel = new VerticalPanel();
73 64 zVPanel.add( new HTML( "&nbsp;" ) );
74 - zVPanel.add( horizontalWithSpacers( fieldLabel, zFieldErrorPanel, stateLabel ) );
65 + zVPanel.add( tif );
75 66 zVPanel.add( new HTML( "&nbsp;" ) );
76 67 zVPanel.add( horizontalWithSpacers( buttonSetValue, buttonSetValueAsUser ) );
77 68