Results 1 to 4 of 4

Thread: Form tag library problem

  1. #1
    Join Date
    Aug 2007
    Posts
    26

    Default Form tag library problem

    HI, I'm new to Spring. I have question about form tag library. I want to create jsp page with dynamic created form. In this form will be many form:select tags. Please look at this example (it's not a valid java code, only some idea):

    Code:
    <form:form name="?" method="post"> 
    
        <c:forEach items="${items}" var="item"> 
             
             <form:select path="?"> 
                  <form:options items="${item.value}" /> 
             </form:select> 
             
        </c:forEach>     
    
    </form:form>
    my question is, how should I set path value, and how must my bean class looks to bind data from this form. Is it possible?

  2. #2

    Default

    Hi Seeed,
    This is the way how you can use spring form tag lib. Say you have a model object called 'institute' and it has a list named 'subjects' in the view. Then you can use it as follows.
    Code:
    <form:form name="ANYNAME" commandName="institute" method="post"> 
    <table>
      <tr>
        <td>Subjects:</td>
        <td><form:select path="subjects" items="${subjects}"/></td>
        <td></td>
      </tr>
    </table>
    </form:form>
    Thats all. You don't need to manually iterate through your list items using jstl core (c) tag lib.

    -/Viraj
    Last edited by viraj; Aug 28th, 2007 at 10:50 PM.

  3. #3
    Join Date
    Aug 2007
    Posts
    26

    Default

    Ok, may I have another request? . Could you write or send me link (I can't find it) how I can handle such form (get data from it, after submit)?

  4. #4

    Default

    Hi Zeed,

    I have attached a working sample. (You can build it and deploy using maven 2) or you can look in to that and get an idea about how you can use controllers ,
    command object, validators and how you can configure acegi security framework with spring.

    It may ask user name and password after deploying.
    Username - viraj
    password - password
    (those are in the WEB-INF/users.properties file)


    -/Viraj
    Attached Files Attached Files

Posting Permissions

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