Results 1 to 5 of 5

Thread: Problems with boolean fields and Spring:bind

  1. #1
    Join Date
    Dec 2004
    Posts
    3

    Default 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. #2
    Join Date
    Aug 2004
    Location
    Sydney
    Posts
    503

    Default

    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?

  3. #3
    Join Date
    Dec 2004
    Posts
    3

    Default

    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

  4. #4
    Join Date
    Aug 2004
    Location
    Stockholm
    Posts
    466

    Default

    Can you show the initBinder-method from your Controller and the command class source ?
    Sincerely,
    /The Cantor

    "Murphy was an optimist"
    (The O'Toole commentary on Murphy's Law)

  5. #5
    Join Date
    Dec 2004
    Posts
    3

    Default

    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

Similar Threads

  1. Problem getting spring:bind to work
    By cminear in forum Web Flow
    Replies: 2
    Last Post: Sep 28th, 2005, 01:16 PM
  2. Replies: 8
    Last Post: Jul 13th, 2005, 11:20 AM
  3. Replies: 2
    Last Post: Sep 15th, 2004, 02:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •