Michael,
I've enclosed excerpts form my ActionForm, Action and JSP - hope the
following helps. The excerpts are from my actual source (had to change
name in some cases), but I cannot send the entire source.
BTW, when I looked I used an array for the field/column names and a map
for the selection choices.
Given an ActionForm with the following properties:
private String[] columnName; // Selected characteristics.
private Map selections = new HashMap(); // Each entry corresponds to
an entry in columnName array.
// Store the entire selections map
public void setSelectionsMap(Map charSel) {
this.selections = charSel;
}
// Retrieve the entire selections map
public Map getSelectionsMap() {
return this.selections;
}
// Retrieve an array of selections for a designated columnName from
the Map
public Object getSelections(String columnName) {
return this.selections.get(columnName);
}
// Store an array of selections for a deisgnated columnName
public void setSelections(String columnName, Object obj) {
this.selections.put(columnName, obj);
}
In the Action place an array of choices (options) for the column under a
key of the columnName:
outForm.setSelections(inForm.getColumnName()[i],choicesArray);
In the JSP, I use JSTL to iterate across the column names and create a
selection list for each:
<c:if test="${empty wizardForm.selectionsMap}">
<c:forEach items="${wizardForm.selectionsMap}"
var="colSelectionsArray">
<td class="Ctr">
<c:set var="cList"
value="${IdentifierCollection_charChoices[colSelectionsArray.key]}"/>
<html-el:select property="selections(${colSelectionsArray.key})"
size="6" multiple="true">
<html-el:options collection="cList" property="id"
labelProperty="name"/>
</html-el:select>
</td>
</c:forEach>
</c:if>
That said, I'm definitely going to look into the LazyDynaBean approach
next time. It looks nice also.
- Richard
michael wrote:
> Your ideas in:
> I have a ver similar form. I just use three separate Maps:
> - one for the type of field it is;
> - one for the name/label;
> - one for the actual value;
> - one for a collection of valid values if its a selection list or set
> of
> redio buttons.
>
> This approach worked for me. I just create the Maps in may action
> (obviously they are all keyed by the field/column name). I use JSTL on
> the web page to iterate through the maps and create the appropriate
> Struts HTML tags.
> are clear to me vis-a-vis creating the form, but how does the
> ActionForm farm the values from the request?
>
> Thanks.
>
> Michael McGrady
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]