Announcement Announcement Module
Collapse
No announcement yet.
Radiobutton with multiple conditions Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Radiobutton with multiple conditions

    I have a question concerning the form-tag. I have a few radio buttons and I want one to be checked. The problem is that value isn't enough, because 1 radio button must be checked when there 2 conditions are met.

    1 radiobutton must be selected when the value is equal to a certain value and a boolean in the pageScope is true.

    Is there a way to do this?

    Something like this:
    Code:
    <form:radiobutton disabled="true" path="known" value="??? || ???" />

  • #2
    I think you can't do it with in the <form:radiobutton /> tag.

    you will have to set the value for the property known in your formBackingObject method.

    lets say you have the following in your view.

    Code:
    <form:radiobutton disabled="true" path="known" value="foo" />
    to make the radio button appear as selected what you have to do is
    Code:
    yourCommandObject.setKnown("foo");
    in your formBackingObject method.

    so when the property known has the value "foo" it will automatically be selected in your view.

    hope this helps you

    Comment


    • #3
      Bleh, I was hoping for a different solution. I'll have to try another solution for this.

      Comment


      • #4
        well there's another way of doing it. It's without the <form:radiobutton> tag, by using <spring:bind> tag

        Code:
        <spring:bind path="known">
             <input name="${status.expression}" type="radio" value="foo"  <c:if test="${status.value == 'foo'}"> selected</c:if> >
        </spring:bind>
        since you want to check for some other conditions you can try something like:

        Code:
        <spring:bind path="known">
             <c:if test="${status.value=='foo' && myBoolean }">
                  <c:set var="selected" value="true"/>
             </c:if>
        
             <input name="${status.expression}" type="radio" value="foo"  <c:if test="${selected}"> checked</c:if> >
        </spring:bind>
        hope this might help you

        Comment

        Working...
        X