struts 2 subset tag

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);
         }
     };
     }
 }


<!--   List with Decider -->
<s:bean name="com.**.MyDecider" var="myDecider"></s:bean>
    <s:subset source="myList" decider="#myDecider" var="myVar">
           <s:iterator value="#attr.myVar">
                <s:property />
           </s:iterator>
    </s:subset>


 

你可能感兴趣的:(bean,struts)