Announcement Announcement Module
Collapse
No announcement yet.
Problems with boolean fields and Spring:bind Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Problems with boolean fields and Spring:bind

    Hi

    I am using Spring in a project I am working on and now I am having problems with the Spring:bind tag reading boolean field in the command class. This form is for editing User and the User command class has m_Admin which is a boolean field and getter and setter and isAdmin( ).

    The following code is on this page and when I try to load a User everything is OK except this Admin field which always turns out to be false, even if the User is an admin. Does anybody know what is wrong.

    Code:
    <spring&#58;bind path="command.admin">
    <input type="edit" name="admin" value="true" value="<c&#58;out value="$&#123;status.value&#125;"/>"/>
    </spring&#58;bind>
    p.s. I am planning on changing this edit field to radio buttons, when this starts to work correctly.

    Sincerely,
    Kjartan Juliusson

  • #2
    You've got the "value" attribute specified twice?

    One thing you might want to try just to be more correct is using ${status.expression} for the input name instead of "admin" just so you've only got the command field specified (hardcoded) once.

    After you've changed those two things, you might want to tell us all what results you're expecting, and then what is actually happening?

    Comment


    • #3
      I changed the code to this:


      Code:
      <input type="edit" name="<c&#58;out value="$&#123;status.expression&#125;"/>" value="<c&#58;out value="$&#123;status.value&#125;"/>"/>
      But it still always shows false, even though the value is supposed to be true.

      Sincerely,
      Kjartan Juliusson

      Comment


      • #4
        Can you show the initBinder-method from your Controller and the command class source ?

        Comment


        • #5
          Thanks for the help, but I just solved the problem, the constructor for the command class was missing the m_Admin value.

          Sincerely,
          Kjartan Juliusson

          Comment

          Working...
          X