No i was wrong works as i thought it would
Need to iterate through the values of the dishes map
public Object[] getDishes() {
return map.values().toArray();
}
<%-- var could be anything the index us the important bit --%>
<c:forEach var="dish" items="${course.dishes}" varStatus="index">
<%-- get the correctly indexed key from the getKeys array-%>
<c:set var="key" value="${course.keys[index.count - 1]}" />
<html:text name="course" property="dish(${key}.name" indexed="true" />
</c:forEach>
renders to
<input type="text" name="course[0].dish(key1).name" value="Fish">
<input type="text" name="course[0].dish(key2).name" value="More Fish">
On 25 Jun 2004, at 01:09, Mark Lowe wrote:
No needs a rethink .
indexed="true" uses whatever iteration tags that its between.. Arses,,
drat and double drat.
On 25 Jun 2004, at 00:27, Mark Lowe wrote:
Not quite.. hang on.
On 25 Jun 2004, at 00:14, Mark Lowe wrote:
A question came up the other week/month where someone nesting 2 deep
and was trying to use a 2 dimesional array. I had the some problem
today and had my chance to combine indexed and mapped properties to
solve the problem.
I want to create a Restaurant Menu editor. So a menu has a few
properties like title and start and end dates for seasonal menus.
So I have 3 action form or nested pojo's
MenuForm
CourseForm
DishBean
I used lazyMap and lazyList to save scoping to session.
MenuForm - has a lazyList or nested courses.
CourseForm - has a lazyMap of dishes and a getKeys() method that
returns map.keySet().toArray()
and dishes are just plain string properties.
public DishBean getDish(String key)
public void setDish(String key,DishBean dish)
The jsp stuff looks something like this.
<html:text property="title" />
<c:forEach var="course" items="${menuForm.courses}">
<html:text name="course" property="title" indexed="true" />
<c:forEach var="key" items="${course.keys}">
<html:text name="course" property="dish(${key}).name"
indexed="true" />
</c:forEach>
</c:forEach>
its not quite as tidy as 2 dimensional array support, but it pretty
clean looking.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]