Announcement Announcement Module
Collapse
No announcement yet.
Binding data from the view to the Form Backing Object Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Binding data from the view to the Form Backing Object

    Hello all,


    I have the following jsp page that populates a table and inserts a radio button (one per row). Upon form submission the value of the selected radio button, which represents an index, is correctly passed to the form baking object, everything works just fine. Here is the jsp:


    Code:
    <table width="1000" bgcolor="f8f8ff" border="2" cellspacing="0" cellpadding="5" align ="center">  
     <form:form method="post" commandName="scriptFill">   
       <tr>
          
          <td align="center" width="30%">Filename</td>
          <td align="center" width="30%">Description</i></td>
          <td align="center" width="30%">Name</td>
          <td align="center" width="10%">Select</td>
       </tr>
      
      
      
      <c:forEach items="${myList}" var="script">
       <tr>
          <td align="left" width="30%"><c:out value="${script.fileName}"/></td>
          <td align="left" width="30%"><i><c:out value="${script.description}"/></i></td>
          <td align="left" width="30%"><i><c:out value="${script.name}"/></i></td>
          <td align="center" width="10%"><form:radiobutton path="index" value="${script.index}" label="" ></form:radiobutton></td>  
       </tr>
      </c:forEach> 
      
      </table>
      <center>
      <i><input type="submit" align="center" value="Populate" ></i>
      </center>
     </form:form>
    What I want to do is eliminate both the radio button and the submit button at bottom of the page, and have one submit button per row. This way the user will only need one click to pass the value of the index to the form backing object. Here is more code with comments for clarity:

    Code:
    <table width="1000" bgcolor="f8f8ff" border="2" cellspacing="0" cellpadding="5" align ="center"> 
     <form:form method="post" commandName="scriptFill">   
       <tr>
          
          <td align="center" width="30%">Filename</td>
          <td align="center" width="30%">Description</i></td>
          <td align="center" width="30%">Name</td>
          <td align="center" width="10%">Select</td>
       </tr>
      
      
      
      <c:forEach items="${myList}" var="script">
       <tr>
          <td align="left" width="30%"><c:out value="${script.fileName}"/></td>
          <td align="left" width="30%"><i><c:out value="${script.description}"/></i></td>
          <td align="left" width="30%"><i><c:out value="${script.name}"/></i></td>
    
           <%-- ELIMINATE THE RADIO BUTTON
          <td align="center" width="10%"><form:radiobutton path="index" value="${script.index}" label="" ></form:radiobutton></td>  
          	--%>
          	   
          	<%-- HAVE A SUBMIT BUTTON THAT PASSES THE RIGHT VALUE OF script.index TO THE INDEX VALUE OF THE FORM BACKING OBJECT
          	<td align="center" width="10%> <input type="submit" align="center"  value="Goto" ></i> </td>
            --%>
          	   
          </td>
          
          
          
         
      </c:forEach> 
      
      </table>
      <center>
                     <%-- ELIMINATE THIS SUBMIT BUTTON <i><input type="submit" align="center" value="Populate" ></i>    --%>
      </center>
     </form:form>

    I'm also including images to make things more clear. I want to go from this:

    Attachment


    to this:

    Attachment



    Please let me know if you have further questions, I might not have been clear.

    Thank you in advance!
    Attached Files
    Last edited by rufu; Sep 3rd, 2011, 06:45 AM.

  • #2
    How about this?
    Code:
    <input type="submit" align="center" value="Populate_${script.index}" >
    when you receive at your server side, you will parse this value and try to get the index number.

    Lets me know if this works for you.

    Comment


    • #3
      Hi p782,

      thanks for the reply but unfortunately it still does not work!
      If I try with your code I get submit buttons with "Populate_${script.index}" on them but with not the correct behavior. The value of the index does not get passed to the controller via the form backing object, it always stays at the default value.

      Any more ideas?

      Thanks!!

      Comment

      Working...
      X