First off, don't use the OptionalValidationFramework.   There's always
a better solution.

Second, I'm still trying to wrap my mind around this problem, so my
answer might be flawed.

Third, I'm going to use a checkbox since I have made almost no use of
radio buttons to date.

A quick test of this code works.

                        <t:saveState id="required" 
value="#{optionalRequired.required}"/>
                        
                        <t:messages globalOnly="true" showDetail="true" />
                        <t:messages globalOnly="false" showDetail="true" />

                        <sandbox:subForm id="requiredForm">
                                <h:selectBooleanCheckbox
                                        value="#{optionalRequired.required}">
                                        <sandbox:submitOnEvent for="executeButton" 
/>
                                </h:selectBooleanCheckbox>
                                <h:commandButton id="executeButton"
                                        value="Immediate Submit"/>
                        </sandbox:subForm>
                        
                        <sandbox:subForm id="textForm">
                                <h:inputText
                                        required="#{optionalRequired.required}"
                                        value="#{optionalRequired.text}">
                                </h:inputText>
                                <h:commandButton
                                        value="Submit"/>
                        </sandbox:subForm>

public class OptionalRequired {

   private boolean required;
   private String text;

   public boolean isRequired() {
       return required;
   }
   public void setRequired(boolean required) {
       this.required = required;
   }
   public String getText() {
       return text;
   }
   public void setText(String value) {
       this.text = value;
   }
}


On 4/15/07, Bjørn T Johansen <[EMAIL PROTECTED]> wrote:
I have small problem and I was wondering how people get around this...

I have a radiobutton with yes or no as the two choices that decides if a text 
field should be rendered or not (choosing yes or no
will submit the page)... Also if this text field is rendered, it is a mandatory 
field and need some input..

If I use required = true on the text field, then when the text field is 
rendered and I choose the other choice of the
radiobuttons (that would hide the text field again), I get an error saying that 
an input is required in the text field (which is
normally correct but not this time, because I am just trying to hide the text 
field again)
If I use immediate = true, then the value of the radiobutton is not set and the 
text field is never rendered...


I guess this is a normal problem but not sure how to best solve this?


Regards,

BTJ

--
-----------------------------------------------------------------------------------------------
Bjørn T Johansen

[EMAIL PROTECTED]
-----------------------------------------------------------------------------------------------
Someone wrote:
"I understand that if you play a Windows CD backwards you hear strange Satanic 
messages"
To which someone replied:
"It's even worse than that; play it forwards and it installs Windows"
-----------------------------------------------------------------------------------------------

Reply via email to