org.apache.struts2.components
类 MergeIterator

java.lang.Object
  继承者 org.apache.struts2.components.Component
      继承者 org.apache.struts2.components.ContextBean
          继承者 org.apache.struts2.components.MergeIterator
所有已实现的接口:
Param.UnnamedParametric

public class MergeIterator
extends ContextBean
implements Param.UnnamedParametric

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.

  1. Display first element of the first list
  2. Display first element of the second list
  3. Display first element of the third list
  4. Display second element of the first list
  5. Display second element of the second list
  6. Display second element of the third list
  7. Display third element of the first list
  8. Display thrid element of the second list
  9. Display third element of the thrid list
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 var="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".

另请参见:
MergeIteratorFilter, MergeIteratorTag

字段摘要
 
从类 org.apache.struts2.components.Component 继承的字段
COMPONENT_STACK
 
构造方法摘要
MergeIterator(com.opensymphony.xwork2.util.ValueStack stack)
           
 
方法摘要
 void addParameter(Object value)
          Adds the given value as a parameter to the outer tag.
 boolean end(Writer writer, String body)
          Callback for the end tag of this component.
 void setVar(String var)
           
 boolean start(Writer writer)
          Callback for the start tag of this component.
 
从类 org.apache.struts2.components.ContextBean 继承的方法
setId
 
从类 org.apache.struts2.components.Component 继承的方法
addAllParameters, addParameter, altSyntax, copyParams, getComponentStack, getParameters, getStack, setActionMapper, setThrowExceptionsOnELFailure, setUrlHelper, usesBody
 
从类 java.lang.Object 继承的方法
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

构造方法详细信息

MergeIterator

public MergeIterator(com.opensymphony.xwork2.util.ValueStack stack)
方法详细信息

start

public boolean start(Writer writer)
从类 Component 复制的描述
Callback for the start tag of this component. Should the body be evaluated?

覆盖:
Component 中的 start
参数:
writer - the output writer.
返回:
true if the body should be evaluated

end

public boolean end(Writer writer,
                   String body)
从类 Component 复制的描述
Callback for the end tag of this component. Should the body be evaluated again?

NOTE: will pop component stack.

覆盖:
Component 中的 end
参数:
writer - the output writer.
body - the rendered body.
返回:
true if the body should be evaluated again

setVar

public void setVar(String var)
覆盖:
ContextBean 中的 setVar

addParameter

public void addParameter(Object value)
从接口 Param.UnnamedParametric 复制的描述
Adds the given value as a parameter to the outer tag.

指定者:
接口 Param.UnnamedParametric 中的 addParameter
参数:
value - the value