龙心客栈
来源: BlogBus 原始链接: http://www.blogbus.com:80/blogbus/blog/diary.php?diaryid=355318 存档链接: https://web.archive.org/web/20041213042605id_/http://www.blogbus.com:80/blogbus/blog/diary.php?diaryid=355318
龙心客栈 一个讨论j2ee技术以及畅谈程序人生的地方,一个有共同兴趣和爱好的朋友相聚的乐园。 <<<How to visit those methods which are not public? | 首页 | 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: then I got what I want. dragonet 发表于 2004-08-28 16:31 引用(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