Announcement Announcement Module
Collapse
No announcement yet.
binding to checkbox Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • binding to checkbox

    hello ..

    i have a command class with a boolean property

    when i bind that to a text box it works fine ...
    but if bind to a check box it results in type conversion error ..

    can any one help me ...!!!!

    thanks

  • #2
    You can set the checkbox value to true. E.g.

    <input type="checkbox" name="<c:out value="${status.expression}"/>" value="true" <c:if test="${status.value}">checked</c:if>>

    otherwise the value defaults to "on" which is probably the cause of your type conversion error.

    There's a thread with some options here.

    Comment


    • #3
      Thank u katentim for ur quick response ..
      i went through the thread u suggested ..

      and specified
      Code:
      <spring&#58;bind path="userRegistration.useShippingAddress"> 
      <input type="hidden" name="_$&#123;status.expression&#125;"> 
      <input type="checkbox" name="$&#123;status.expression&#125;" id="$&#123;status.expression&#125;" <core&#58;if test="$&#123;status.value&#125;">checked</core&#58;if>/> 
      </spring&#58;bind>
      i am using it inside a wizard form controller ( does that make any difference ?)

      the field always show as unchecked ..
      am i doing any thing wrong here

      Comment


      • #4
        ok when i mixed the solutions it worked ..

        Code:
        <spring&#58;bind path="userRegistration.useShippingAddress"> 
          <input type="hidden" name="_<core&#58;out value="$&#123;status.expression&#125;"/>"> 
          <input type="checkbox" name="<core&#58;out value="$&#123;status.expression&#125;"/>" value="true" id="<core&#58;out value="$&#123;status.expression&#125;"/>" <core&#58;if test="$&#123;status.value&#125;">checked</core&#58;if>/> 
        <span class="error"> <core&#58;out value="$&#123;status.errorMessage&#125;"/></span>
        </spring&#58;bind>
        also i was giving

        name="_${status.expression}"
        instead of
        name="_<core:out value="${status.expression}"/>"

        thanks

        Comment

        Working...
        X