Suppose that I have a list of business primary key numbers and a java Map o开发者_高级运维f OrderId numbers to Orders. How would I retrieve the order object?
Action Form
// assume proper getters and setters and that both objects are initialized
private List<CustomerOrders> orders;
private Map<Integer, Order> orderIdMap;
// JSP
<s:iterator value="orders">
<s:property value="%{orderIdMap['what_goes_here'].orderDate}" />
</s:iterator>
In the "what_goes_here" blank, I've tried the following:
%{orders.orderId}
%{orderId}
<s:property value="%{orders.orderId}" />
<s:property value='%{orders.orderId}' />
I also tried it without the single quotes before what_goes_here and it didn't work either.
So how do I access the value from the Map using the key which is the current index of the orders list?
Thanks!
This is untested but try something like
<s:property value="%{getOrderIdMap().get([0].getOrderId()).getOrderDate()}"/>
精彩评论