litesoft
@ 948
litesoft / trunk / GWT_Sandbox / FormEngine / src / com / temp / client / foundation / widget / input / RadioButtonInputField.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
package com.temp.client.foundation.widget.input; import com.google.gwt.user.client.ui.*; import com.temp.client.foundation.widget.input.fieldsupport.*; import com.temp.client.foundation.widget.input.support.*; import com.temp.shared.utils.*; /** * Due to the nature of the way GWT RadioButtons Work, A "Group" (name) must be specified! */ public class RadioButtonInputField extends AbstractGeneratedInputField<Boolean, RadioButtonInputField> { private static final String STYLE = "field-radioButton"; private String group; public String getGroup() { return group; } public void setGroup( String name ) { assertBuildMode( "setGroup" ); setValidatedGroup( Validate.noEmptyIdentifier( "group", name ) ); } public final RadioButtonInputField group( String name ) { assertBuildMode( "group" ); setValidatedGroup( Validate.noEmptyIdentifier( "group", name ) ); return inheritanceLeaf(); } protected void setValidatedGroup( String name ) { group = name; } @Override protected InputFieldAccessor<Boolean> createBaseAccessor() { RadioButton field = new OurRadioButton( Validate.noEmpty( "group", group ) ); return createBaseAccessor( new RadioButtonValueAdapter( field ), field, STYLE, field ); } private static class OurRadioButton extends RadioButton { // For NameToID private String name; public OurRadioButton( String groupName ) { super( groupName ); } @Override public String getName() { return name; } @Override public void setName( String name ) { this.name = name; } } } |