You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Apache Wiki <wi...@apache.org> on 2005/07/14 17:12:17 UTC

[Struts Wiki] Update of "StrutsCatalogLazyList" by RickReumann

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Struts Wiki" for change notification.

The following page has been changed by RickReumann:
http://wiki.apache.org/struts/StrutsCatalogLazyList

------------------------------------------------------------------------------
  }}}
  
  
+ An easier/cleaner way? ( Rick Reumann )
+ 
+ Someone feel free to edit this, but doesn't that solution above tie your ActionForm to just one List? What if your form has several lists that need to grow? 
+ 
+ Someone gave me this solution and it works great. Since reset is always called it makes sure you have your LazyList initialized and then it just grows as needed. You can set this up for other Lists you need in your form as well.
+ 
+ {{{
+ 
+   import org.apache.commons.collections.Factory;
+   import org.apache.commons.collections.ListUtils;
+   import java.util.List;
+   import java.util.ArrayList;
+ 
+   public class SkillActionForm extends ActionForm  {
+ 
+       protected List skills;
+ 
+       public List getSkills() {
+           return skills;
+       }
+ 
+       public void setSkills(final List skills) {
+           this.skills =  skills;
+       }
+ 
+       public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest) {
+         skills = ListUtils.lazyList(new ArrayList(),
+         new Factory() {
+             public Object create() {
+                 return new Skills();
+             }
+         });
+     }
+ 
+   }
+ 
+ }}}
+ 
+ 
+ 
  === LazyDynaBean / LazyValidatorForm ===
  
  '''N.B.''' Solutions here require '''Struts 1.2.4''' and '''Bean Utils 1.7.0'''

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org