| java.lang.Object org.apache.struts2.components.Component org.apache.struts2.components.MergeIterator
MergeIterator | public class MergeIterator extends Component implements UnnamedParametric(Code) | |
Component for MergeIteratorTag, which job is to merge iterators and successive
call to the merged iterator will cause each merge iterator to have a chance to
expose its element, subsequently next call will allow the next iterator to expose
its element. Once the last iterator is done exposing its element, the first iterator
is allowed to do so again (unless it is exhausted of entries).
Internally the task are delegated to MergeIteratorFilter
Example if there are 3 lists being merged, each list have 3 entries, the following will
be the logic.
- Display first element of the first list
- Display first element of the second list
- Display first element of the third list
- Display second element of the first list
- Display second element of the second list
- Display second element of the third list
- Display third element of the first list
- Display thrid element of the second list
- Display third element of the thrid list
- id (String) - the id where the resultant merged iterator will be stored in the stack's context
public class MergeIteratorTagAction extends ActionSupport {
private List myList1;
private List myList2;
private List myList3;
public List getMyList1() {
return myList1;
}
public List getMyList2() {
return myList2;
}
public List getMyList3() {
return myList3;
}
public String execute() throws Exception {
myList1 = new ArrayList();
myList1.add("1");
myList1.add("2");
myList1.add("3");
myList2 = new ArrayList();
myList2.add("a");
myList2.add("b");
myList2.add("c");
myList3 = new ArrayList();
myList3.add("A");
myList3.add("B");
myList3.add("C");
return "done";
}
}
<s:merge id="myMergedIterator1">
<s:param value="%{myList1}" />
<s:param value="%{myList2}" />
<s:param value="%{myList3}" />
</s:merge>
<s:iterator value="%{#myMergedIterator1}">
<s:property />
</s:iterator>
This wil generate "1aA2bB3cC".
See Also: org.apache.struts2.util.MergeIteratorFilter See Also: org.apache.struts2.views.jsp.iterator.MergeIteratorTag |
MergeIterator | public MergeIterator(ValueStack stack)(Code) | | |
Methods inherited from org.apache.struts2.components.Component | public void addAllParameters(Map params)(Code)(Java Doc) public void addParameter(String key, Object value)(Code)(Java Doc) public boolean altSyntax()(Code)(Java Doc) public void copyParams(Map params)(Code)(Java Doc) protected String determineActionURL(String action, String namespace, String method, HttpServletRequest req, HttpServletResponse res, Map parameters, String scheme, boolean includeContext, boolean encodeResult)(Code)(Java Doc) protected String determineActionURL(String action, String namespace, String method, HttpServletRequest req, HttpServletResponse res, Map parameters, String scheme, boolean includeContext, boolean encodeResult, boolean forceAddSchemeHostAndPort, boolean escapeAmp)(Code)(Java Doc) protected String determineNamespace(String namespace, ValueStack stack, HttpServletRequest req)(Code)(Java Doc) public boolean end(Writer writer, String body)(Code)(Java Doc) protected boolean end(Writer writer, String body, boolean popComponentStack)(Code)(Java Doc) protected StrutsException fieldError(String field, String errorMsg, Exception e)(Code)(Java Doc) protected Component findAncestor(Class clazz)(Code)(Java Doc) protected String findString(String expr)(Code)(Java Doc) protected String findString(String expr, String field, String errorMsg)(Code)(Java Doc) protected Object findValue(String expr)(Code)(Java Doc) protected Object findValue(String expr, String field, String errorMsg)(Code)(Java Doc) protected Object findValue(String expr, Class toType)(Code)(Java Doc) public Stack getComponentStack()(Code)(Java Doc) public String getId()(Code)(Java Doc) public Map getParameters()(Code)(Java Doc) public ValueStack getStack()(Code)(Java Doc) protected void popComponentStack()(Code)(Java Doc) public void setActionMapper(ActionMapper mapper)(Code)(Java Doc) public void setId(String id)(Code)(Java Doc) public boolean start(Writer writer)(Code)(Java Doc) protected String toString(Throwable t)(Code)(Java Doc) public boolean usesBody()(Code)(Java Doc)
|
|
|