Description

NOTE: JSP-TAG

A tag that takes an iterator and outputs a subset of it. It delegates to com.opensymphony.webwork.util.SubsetIteratorFilter internally to perform the subset functionality.

Parameters

Name

Required

Default

Type

Description

count false   Integer Indicate the number of entries to be in the resulting subset iterator
source false   Object/String Indicate the source of which the resulting subset iterator is to be derived base on
start false   Integer Indicate the starting index (eg. first entry is 0) of entries in the source to be available as the first entry in the resulting subset iterator
decider false   com.opensymphony.webwork.util.SubsetIteratorFilter.Decider Extension to plug-in a decider to determine if that particular entry is to be included in the resulting subset iterator
id false   String The id of the tag element.

Examples

public class MySubsetTagAction extends ActionSupport {
     public String execute() throws Exception {
	   l = new ArrayList();
	   l.add(new Integer(1));
	   l.add(new Integer(2));
	   l.add(new Integer(3));
	   l.add(new Integer(4));
	   l.add(new Integer(5));
	   return "done";
    }


    public Integer[] getMyArray() {
	   return a;
    }

    public List getMyList() {
	   return l;
     }

     public Decider getMyDecider() {
	return new Decider() {
		public boolean decide(Object element) throws Exception {
			int i = ((Integer)element).intValue();
			return (((i % 2) == 0)?true:false);
		}
	};
	}
}
<!-- A: List basic -->
   <ww:subset source="myList">
     <ww:iterator>
	    <ww:property />
     </ww:iterator>
   </ww:subset>
<!-- B: List with count -->
   <ww:subset source="myList" count="3">
	     <ww:iterator>
		     <ww:property />
	     </ww:iterator>
    </ww:subset>
<!--  C: List with start -->
     <ww:subset source="myList" count="13" start="3">
	       <ww:iterator>
		     <ww:property />
	       </ww:iterator>
     </ww:subset>
<!--  D: List with id -->
     <ww:subset id="mySubset" source="myList" count="13" start="3" />
     <%
	        Iterator i = (Iterator) pageContext.getAttribute("mySubset");
         while(i.hasNext()) {
     %>
     <%=i.next() %>
     <%  } %>
<!--  D: List with Decider -->
     <ww:subset source="myList" decider="myDecider">
	           <ww:iterator>
	            <ww:property />
           </ww:iterator>
     </ww:subset>