struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Struts Wiki] Trivial Update of "StrutsCatalogLazyList" by RickReumann
Date Thu, 29 Dec 2005 21:27:27 GMT
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

The comment on the change is:
removed my comment/question since it shouldn't be on the wiki

------------------------------------------------------------------------------
  Enjoy,
  Derek Clarkson
  
+  
  
- === Problem - How do we deal with Lists of objects that contain Lists? ===
- 
- I'm still stumped with the best way to handle cases where your nesting goes a bit deeper
than the examples shown here. For example lets assume you want to edit on a single form a
list of Employees - where you want to be able to edit their name AND a List of phone numbers:
- 
- {{{
- Employee              Phone Numbers
- --------              -------------
- John Doe              888-888-8888
-                       888-111-1111
-                       222-222-2222
- Bill Boo              111-111-3333
-                       444-333-3333
- }}}
- 
- So we might have basically a List of Employee objects where Employee has:
- {{{
- Employee:   
-    String name;
-    List phoneNumbers;
- }}}
- 
- Our form bean  can have:
- {{{
- ActionForm:
-    List employees;
- }}}
- 
- Here's the problem.... in the reset method you can set a LazyList to wrap the Employees
but there is still the problem of the internal List of phoneNumbers in each Employee.
- 
- I was trying:
- 
- {{{
- public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest) {
- 
-     employees = ListUtils.lazyList(new java.util.ArrayList(), new Factory() {
-         public Object create() {
-             return buildEmployee();
-         }
-     });
-  }
- 
- private Employee buildEmployee() {
-     //This really isn't working, I'll still get index out of bounds, when 
-     //trying to set an index of the phoneNumbers list
-     Employee emp = new Employee();
-     List phoneNumbers = ListUtils.lazyList(new java.util.ArrayList(), new Factory() {
-         public Object create() {
-             return new String();
-         }
-     });
-     emp.setPhoneNumbers( phoneNumbers );
-     return emp;
-      
- }
- }}}
- 
- Of course all of these problems go away if I just use the Session to store the form, but
I really want to figure out a nice way to get this to work using the Request. Feel free to
delete this once a nice solution is proposed.
- 

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


Mime
View raw message