... If you're going to use the example classes I provided note that method 
onActionFromResetvalues should also reset the vowel var

public void onActionFromResetvalues() {
        booleanValue = null;
        textValue = null;
        vowel = null; //<<<missing reset

    }
bye,
 Luca

----- Original Message -----
> From: "Luca Menegus" <luca.mene...@dbmsrl.com>
> To: "Tapestry users" <users@tapestry.apache.org>
> Sent: Monday, September 2, 2013 9:35:44 PM
> Subject: [T5.3.7 BUG] RadioGroup doesn't honor disabled parameter
> 
> Hi all,
> I just found a bug with RadioGroup/Radio not honoring their disabled state
> (It drove me quite mad...).
> 
> In RadioGroup submission is processed regardless of the disabled parameter
> value.
> 
> In Fields derived from AbstractField submission processing is skipped
> altogether when the field is disabled (From Abstract Field):
> [...]
> 
> 
> private void processSubmission()
> {
> if (!disabled)
> processSubmission(controlName);
> }
> [...]
> 
> The fix should be quite trivial. Anyway I might provide a patch (with test)
> but I'm not sure as I'm going abroad and don't know if I'll have access to
> the internet in the next days.
> 
> While I was debugging it I created a test class [1] and page [2] that can be
> used to analyse what's going on .
> 
> One last thing is that the behavior of radio group together with Boolean
> values (Capital B) is somehow unexpected as it would set the value of the
> bound property to false even if no selection has been made (that's probably
> because there is a coercion from null to false - and has nothing to do with
> the component disabled state anyway). My use case is that I want to force my
> user to make an explicit decision on some contract agreement. One "solution"
> could be to ignore standard coercion in RadioGroup iif the bound value class
> is Boolean
> 
> bye,
> Luca
> 
> [1]
> 
> 
> public class TestRadio {
> 
> @Persist
> @Property
> private Boolean booleanValue;
> @Persist
> @Property
> private String textValue;
> 
> @Persist
> @Property
> private boolean formDisabled;
> 
> @Persist
> @Property
> private VOWEL_ENUM vowel;
> 
> public Boolean getOn() {
> return Boolean.TRUE;
> }
> 
> public Boolean getOff() {
> return Boolean.FALSE;
> }
> 
> public VOWEL_ENUM getA() {
> return VOWEL_ENUM.A;
> }
> 
> public VOWEL_ENUM getE() {
> return VOWEL_ENUM.E;
> }
> 
> public VOWEL_ENUM getI() {
> return VOWEL_ENUM.I;
> }
> 
> public VOWEL_ENUM getO() {
> return VOWEL_ENUM.O;
> }
> 
> public VOWEL_ENUM getU() {
> return VOWEL_ENUM.U;
> }
> 
> public boolean isBooleanValueNull() {
> return booleanValue == null;
> }
> 
> public boolean isTextValueNull() {
> return textValue == null;
> }
> 
> public boolean isVowelNull() {
> return vowel == null;
> }
> 
> public void onActionFromResetvalues() {
> booleanValue = null;
> textValue = null;
> }
> 
> public void onActionFromEnableFormControls() {
> formDisabled = false;
> }
> 
> public void onActionFromDisableFormControls() {
> formDisabled = true;
> }
> 
> public static enum VOWEL_ENUM {
> A, E, I, O, U;
> }
> }
> [2]
> 
> 
> <?xml version="1.0" encoding="UTF-8"?>
> <html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd";
> xmlns:p="tapestry:parameter">
> <h2>DATA</h2>
> <p>
> booleanValue is '${booleanValue}'
> <t:if test="booleanValueNull"> (NULL)</t:if>
> </p>
> <p>
> textValue is '${textValue}'
> <t:if test="textValueNull"> (NULL)</t:if>
> </p>
> <p>
> vowel is '${vowel}'
> <t:if test="vowelNull"> (NULL)</t:if>
> </p>
> <t:actionLink t:id="resetvalues">Reset values</t:actionLink>
> <h2>CONTROL DISABLE STATUS</h2>
> <t:if test="formDisabled">
> <p>
> Form controls are
> <b>disabled</b>
> !!
> </p>
> <t:actionLink t:id="enableFormControls">Enable form controls</t:actionLink>
> <p:else>
> <p>Form controls are enabled</p>
> <t:actionLink t:id="disableFormControls">Disable form controls</t:actionLink>
> </p:else>
> </t:if>
> 
> <h2>FORM</h2>
> <t:form>
> <b>Expected behavior</b>
> <p>When disabled I will not update my value</p>
> <t:label for="textValue" />
> <t:textField t:id="textValue" disabled="formDisabled" />
> 
> <b>Buggy behavior</b>
> <p>When disabled I'm still updating my value (and since no value is selected
> I will set it to null)</p>
> <t:label for="vowel" />
> <t:radioGroup t:id="vowel" disabled="formDisabled">
> <t:label for="A" />
> <t:radio t:id="A" />
> <t:label for="E" />
> <t:radio t:id="E" />
> <t:label for="I" />
> <t:radio t:id="I" />
> <t:label for="O" />
> <t:radio t:id="O" />
> <t:label for="U" />
> <t:radio t:id="U" />
> </t:radioGroup>
> <b>Buggy and somehow unexpected behavior</b>
> <p>When disabled I'm still updating my value.</p>
> <p>Moreover I'm updating my value to false (possibly because there is a
> coercion from null to false)</p>
> <p>This is somehow unexpected as I can't set my value to null (or unselected)
> even when I'm enabled</p>
> <t:label for="booleanValue" />
> <t:radioGroup t:id="booleanValue" disabled="formDisabled">
> <t:label for="on" />
> <t:radio t:id="on" />
> <t:label for="off" />
> <t:radio t:id="off" />
> </t:radioGroup>
> <t:submit />
> </t:form>
> </html>
> 
> 
> 
> 
> 
> 
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to