Reputation: 779
I using struts2 "s:iterate" tag. My collection name keeps on changing. So i wants to use an expression for specifying the value. According tld expressions are not allowed for "value" in "s:iterate" tag.
is there way to keep the value variable, instead of a static value.
<s:iterator value="${param.listName}" status="status" >
</s:iterator>
Something like above.I would like use the listName from request parameter to specify the name of the collection to the iterate tag.
Upvotes: 0
Views: 414
Reputation: 20323
Do you mean something like this:
<s:iterator var="reportHeader" value="%{#session.myList}" status="headerNumber" >
</s:iterator>
yep works like a charm.
Update:
myList
in session.myList
is a String
which represents the key.
So corresponding action code will be
public String execute(){
HttpSession session = ServletActionContext.getRequest().getSession();
session.setAttribute("myList", new ArrayList<String>());
return Action.SUCCESS;
}
Upvotes: 1