Rick Reumann wrote:
Michael McGrady wrote the following on 9/16/2004 3:18 PM:
SECOND BeanUtils
I would have BeanUtils populate a List and then have the logic in the form populate the Object FooBar. That is, I would do the same thing in populating the FooBar class as mining, retrieving, etc. that class. Just use a list or other standard container for the BeanUtils operations.
Make sense?
Actually no:) I'm pretty lost now. Using the Session seems so much easier:)
The field that is passed back and forth from ActionForm to view is the List field, not the FooBar field. List holds the values of FooBar which are retrieved by recursion.
If you bored you can try to show me what you would change to get the following example to work (Ill use UserForm for the Struts stuff and FooBar for the non-struts class):
class UserForm extends ActionForm { private FooBar fooBar; //setFooBar(FooBar foobBar) //getFooBar();
protected List listOfFooBarNames;
public void reset(ActionMapping mapping, HttpServletRequest request) { logic(outsideFooBar); }
private void logic(FooBar parentFooBar) { FooBar childFooBar;
// A. Wrap non-collection name values into an appropriate list;
listOfFooBarNames = new LinkedList(); listOfFooBarNames.add(parentFooBar.getName());
// System.out.println(parentFooBar.getName());
// B. Use this logic to repeat the above recursively. Collection collection;
if((collection = parentFooBar.getCollection()) != null) { Iterator iter = ((LinkedList)collection).listIterator(); while(iter.hasNext()) { childFooBar = (FooBar)iter.next(); logic(childFooBar); } } } }
class FooBar { private String name; private Collection fooBars; //set/gets }
//In SetUp of an Action
//business logic called that returns a FooBar object, but for this
//test just create a FooBar object and add a Collection of 2 FooBars to
//each Collection. 2 deep is fine. Add to form... userForm.setFooBar(fooBar);
//forward to JSP form....
//on JSP form (I'll end up with tags to do this etc) but for now..
<nested:text property="fooBar.name"/> <nested:iterate property="fooBar.fooBars"> <nested:text property="name"/> <nested:iterate property="fooBars"> <nested:text property="name"/> </nested:iterate> </nested:iterate>
I think I need more of a concrete example of what you'd change to make this work. What I think would work is wrapping the FooBar object in UserForm inside of a FooBarWrapper. Haven't figured out exactly how I'd implement it but you and Niall have given me some ideas.
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]