You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by Sy...@aig.com on 2003/08/11 04:39:39 UTC

Re: how to submit a selected item of a collection

I need help with submission of an item of a collection.

I display a collection of items with each item having a button.  I allow 
user to click the button to select the item. When I try to get a value 
from the Form in my Action, there is nothing.  Here is my code.  The 
display part is ok.

//jsp to display and get selected life
<logic:iterate id="oneLife" name="lives" >
<member>
<tr>
    <td width="160"><bean:write name="oneLife" property="surName"/></td>
    <td width="160"><bean:write name="oneLife" property="firstName"/></td>
    <td><html:submit>Choose</html:submit></td> 
</tr>
</member>
</logic:iterate>

// My form to capture data from the selected item
public class SelectLifeForm extends ActionForm {
        private String surName = null;
        private String firstName = null;

    // with getter and setter for each field.
}

// My action class to do something like perform a sql base on the two 
values submitted.
public class SelectLifeAction extends Action {

        public ActionForward execute(
                ActionMapping mapping,
                ActionForm form,
                HttpServletRequest request,
                HttpServletResponse response)
                throws Exception {

                SelectLifeForm selectLifeForm = (SelectLifeForm) form;

                System.err.println("*** selectLifeForm = " + 
selectLifeForm.getSurName() ); 
                System.err.println("*** selectLifeForm = " + 
selectLifeForm.getFirstName() ); 
            // selectLifeForm have null values in both fields.

            ...

      }

}