Hi,

[I'm using struts 1.2.7  (with EL from contrib) on Tomcat 5.5.9].

I'm attempting to submit variable amounts of form data in a table following
the model of James Turner: http://www.developer.com/java/ejb/article.php/10931_3321521_1. The goal is to retrieve items (user-configured "alerts") from a DB, present descriptions of them as lines in a table, with checkboxes for "edit" and "delete" added to each.
Here is the relevant part of my struts-config.xml:

<form-bean name="dynamicEditAlertForm"
type="org.apache.struts.action.DynaActionForm" > <form-property name="alertsArray" type="com...AlertChoiceDesc[]" />
</form-bean>

<action path="/SetupEditAlertForm" name="dynamicEditAlertForm"
     validate="false"
     scope="session"
     type="com...SetupEditAlertFormAction" >
     <forward name="success" path="begin.work"/>
</action>
<action path="/EditAlert" name="dynamicEditAlertForm"
     validate="false"
     scope="session"
     type="com...EditAlertAction" >
     <forward name="success" path="edit.alert"/>
</action>

Successful login forwards to /SetupEditAlertForm, which is intended to create
the session-scoped form which will be associated with the form for choosing
(on page begin.work) the items to be edited;  The form action is /EditAlert
(see jsp below).

Here is the relevant part of the execute code for SetupEditAlertFormAction:

   List<AlertChoiceDesc> alertChoiceDescs
       = alertsDBMgr.getAlertBeansChoiceDescs(); //get alerts from db

   AlertChoiceDesc[] alertLines
= new AlertChoiceDesc[alertChoiceDescs.size()]; alertChoiceDescs.toArray(alertLines); df.set("alertsArray", alertLines); return mapping.findForward("success");

The class AlertChoiceDesc is a vanilla Bean (with properties id, description, etc.)

The JSP page 'begin.work' is defined in a struts-tiles.xml definition.  The
relevant part of the page body is this:

   <html:form action="/EditAlert">
   <table border="1" cellspacing="1" cellpadding="1">
   <tr> <th>ID</th> ...  <th>Edit</th> <th>Delete</th> </tr>
<c:forEach var="alertDesc" items="${dynamicArrayForm.map.alertsArray}">
       <tr><td><c:out value="${alertDesc.id}"/></td>
           <td><c:out value="${alertDesc.description}"/></td>
       ...
           <td>--</td> // placeholders for checkboxes to be added
           <td>--</td>
       </tr>
   </c:forEach>
<tr> <td><html:submit value="Edit"/></td>
   <td><html:submit value="Delete"/></td></tr>

   </table>
   </html:form>
My current db contains 7 user alerts. Debugging SetupEditAlertFormAction shows
that the variable alertLines contains the expected 7 AlertChoiceDesc objects
at the line: df.set("alertsArray", alertLines); However, the JSP page 'begin.work' displays the table with only the header and
the submit buttons -- no data rows.

I've tried this using both
type="org.apache.struts.action.DynaActionForm" > as shown here, and with the type
          type="org.apache.struts.validator.DynaValidatorForm"
used by Turner.  The behavior is the same in both cases>

I hope someone can help me see what I'm missing here.

More generally, I'm not committed to this specific pattern. I'll be happy to use any other technique which would allow me to present a variable number of data items to the user, with checkbox (or radio buttons) attached, and
then obtain the user's choices.

Thanks in advance,
Ken Bowen


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to