一个讨论j2ee技术以及畅谈程序人生的地方,一个有共同兴趣和

一个讨论j2ee技术以及畅谈程序人生的地方,一个有共同兴趣和爱好的朋友相聚的乐园。 | 首页 | pooly design on Swing & design pattern>>> a trick about 'How to update multiple value in collection' on Struts 时间: 2004-08-28 There is a javabean Test,has two properties: name,pass.In my program I have multiple ojbects of Test.I want to add,delete,update them in batch.Of cause I select iterate tag to do this job.There are 3 keys,one is in jsp file.Please notice the red workds. my jsp like followed: <logic:iterate id="test" name="testActionForm" property="list" type="org.apache.struts.webapp.example.Test" scope="request"> <html:text name=" test " property="name" indexed="true" /><html:text name="test" property="pass" indexed="true" readonly="true"/> </logic:iterate> Second should be formbean: private ArrayList list=new ArrayList(); public Test get Test (int index){ if(list == null){ list = new ArrayList(); list.add(new Test()); } while(index >= list.size()){ list.add(new Test()); } return (Test)list.get(index); } public void set Test (int index, Test line){ if(list == null){ list = new ArrayList(); list.add(new Test()); } while(index >= list.size()){ list.add(new Test()); } this.list.set(index, line); } The third is in struts-config.xml: <action name="testActionForm" type="org.apache.struts.webapp.example.TestAction" validate="false" scope="request" path="/testAction" > <forward name="new" path="/test.jsp"/> <forward name="test" path="/test1.jsp"/> </action> then I got what I want. dragonet 引用(Trackback0) 评论 发表评论 最后更新 pooly design on Swing & design pattern an article for thought about Swing What method does the container calls when instantiating servlet log4j synthetically How to estimate a trick about 'How to update multiple value in collection' on Struts How to visit those methods which are not public? 学习java 八卦1: 瑜珈 Analysis Mechanism

原始快照:web.archive.org