Brent,
I applaud the effort you put into creating an example -- to minimize confusion, perhaps it should be minimilly updated as follows:
For
struts-config.xml For the
action "/DisplayOrderIndexed", remove
/WEB-INF/ from the "success" forward. Nothing can be served out of WEB-INF.
For the
action "/SaveOrderIndexed", remove ficticious attribute "indexed", specifically, delete the line which reads
indexed="/DisplayOrderIndexed.do".
For
OrderIndexedForm (form bean) The general problem is that the indexed property setter, with signature
public void setOrderItem(int index, OrderItem o) is missing, and the comment which is currently adjacent to "getOrderItem" goes
instead with the missing "setOrderItem" method. Plus, body of "getOrderItem" indexed-property getter need only contain:
// return the requested item
return (OrderItem) orderList.get(index);
, the lines:
// make sure that orderList is not null
if(this.orderList == null)
{
this.orderList = new ArrayList();
}
// indexes do not come in order, populate empty spots
while(index >= this.orderList.size())
{
this.orderList.add(new OrderItem());
}
serve only to create a bug which would clear
orderList collection each time the indexed
getter is invoked. This bug might be serious enough to suggest removal of the example from publication until corrected.
The missing "setOrderItem" should look something like:
For
order_indexed.jsp: Perhaps
indexed="true" attributes should be added to:
<td><bean:write name="orderItem" property="productId" /></td>
<td><bean:write name="orderItem" property="productName" /></td>
something like:
I was just looking over the example, and I saw the *big* problems with OrderIndexedForm and was just concerned that a neophyte might get frustrated with trying to make this work, and be left with a bad impression of the
Struts framework. Again, excellent effort, and I do appreciate any consideration you may give to this feedback. Thank you very much.
-Jim