Results 1 to 3 of 3

Thread: <form:options tag

  1. #1
    Join Date
    Sep 2007
    Posts
    16

    Default <form:options tag

    Hi,

    Can't seem to find any docs on how to use the <form:options tag completely. I found the following, which is ok for the HTML, what what exactly does the 'code' and the 'name' correspond to?
    I guess this is something in the 'countryList'. Would 'countryList' be a list of objects called country containing attributes of 'code' and 'name'? I need to find out how to define the java code to interact with this.

    <tr>
    <td>Country:</td>
    <td>
    <form:select path="country">
    <form:option value="-" label="--Please Select"/>
    <form:options items="${countryList}" itemValue="code" itemLabel="name"/>
    </form:select>
    </td>
    <td></td>
    </tr>

    Thanks,
    Nick..

  2. #2
    Join Date
    Sep 2004
    Location
    Manchester, NH
    Posts
    1,236

    Default

    Right, "code" and "name" correspond to properties on objects in the Collection represented by the JSTL expression "${countryList}". "countryList" would usually be a named element that you put into your Model in your controller (most likely referenceData method, for *FormControllers). path=country on the form:select corresponds to the "country" property on the command object (or whatever path you bound in your form:form tag). Hope that helps?
    Peter Mularien | Blog
    Author, Spring Security 3 (Book) - Packt Publishing, Available in print and eBook form
    SCJP 5, Oracle DBA
    Any postings are my own opinion, and should not be attributed to my employer or clients.


  3. #3
    Join Date
    Sep 2007
    Posts
    16

    Default

    Yeah, that works well. Thanks.
    Nick..

Posting Permissions

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