Two questions: 1 - In our situation we will be getting a *result* object with an internal list from the backend that is similar to the MonkeyBean. I would NOT be able to change it's implementation (ie:adding LazyCollections) . How could I achieve the same thing? Would I need to create to temporary list wrappers that would be used to manually insert the newly created lists ?
2 - Are the LazyCollections public now. The last I heard they were on there way to Commons. I have been checking Arrons site and have seen to mention of them. I also understand that some of the tutorials will be updated with the lazy collections instead of putting the list in session. Is this the case? Thanks "hemant" <[EMAIL PROTECTED]> on 07/24/2002 10:02:05 AM Please respond to "Struts Users Mailing List" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> cc: Subject: Re: Wrapping Collections in LazyList to auto-populate form on Submit Arron Great answer! Will experiment with my code based on your suggestions and let you know Thanks for your time Regards hemant ----- Original Message ----- From: "Arron Bates" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <[EMAIL PROTECTED]> Sent: Wednesday, July 24, 2002 10:46 AM Subject: Re: Wrapping Collections in LazyList to auto-populate form on Submit > The seed beans would be child beans to the banana beans. You'd ask the > monkey bean for the collection of bananas, and once you have a banana, > you'd ask the banana for the list of it's seeds. So, the list becomes a > member of the banana. Looking a little like this... > > > public class BananaBean { > public String getFlavour() { return flav; } > public void setFlavour(String str) { flav = str; } > > public List getSeeds() { return seedList; } > > private List seedList = LazyCollections.lazyList(new ArrayList(), > SeedBean.class); > private String flav; > } > > > > Nested beans are all about composition. Each nesting level will be > composed of that beneath it. Monkey's don't manage seeds, they manage > bananas. Seed management is up to the Banana. If there's another level, > then the seed bean will take care of that. The Monkey examples of my > site are an example of all this. What may be confusing is that they > build objects and at times their children for sake of convenience. But > the member collections themselves are always attached to the object > they're concerned with. > > So when the request comes in, it will make the monkey object for the > form. It'll then ask for the banana at the index. When the banana's made > it will make the lazy wrapped list of seeds. so when an update for a > seed comes in, then it will make the seed object for the banana. > > Once you have one level going, the rest are just as easy. From one to a > hundred list levels, it's all the same. Other things come to light > too... you don't have to always have the model start with monkey. Say > another form which is banana specific, you can use the same banana > object in another model, and it'll work just as well. Gotta love OOP :) > > > Arron. > > > On Wed, 2002-07-24 at 23:43, hemant wrote: > > Arron, > > > > Thanks for responding. > > > > Things seem to be clearer now. I have a question to ask though. > > > > We all know Bananas have seeds. (So a BananaBean can have a collection of > > seeds.) > > > > Now I have a situation where I have to set the property of the seed bean via > > the JSP on submit. > > > > Lets have a seed bean > > > > public class SeedBean { > > public String getColor() { return color; } > > public void setColor(String str) { color= str; } > > private String color; > > } > > > > Now in the MonkeyBean (Which is the formbean ) can I say the following? > > > > public class MonkeyBean { > > public List getBananas() { return bananas; } > > private List bananas = LazyCollections.lazyList(new > > ArrayList(LazyCollections.lazyList(new ArrayList(), SeedBean.class)), > > BananaBean.class); > > } > > > > > > I tried doing the same but it didnt work :( > > > > Thanks for your time > > hemant > > > > > > > > > > ----- Original Message ----- > > From: "Arron Bates" <[EMAIL PROTECTED]> > > To: "Struts Users Mailing List" <[EMAIL PROTECTED]> > > Sent: Tuesday, July 23, 2002 10:19 AM > > Subject: Re: Wrapping Collections in LazyList to auto-populate form on > > Submit > > > > > > > Hemant, > > > > > > Sorry about the issues you're having, but at face value it seems that > > > you're almost trying too hard. Without seeing the rest of your code, > > > it's hard to see what your generateWrappedCollection() method is trying > > > to acheive, so I'll try to answer with code... > > > > > > > > > With the collection wrapping, it's a simple one liner in the bean. For > > > example, in all my monkey examples, they all return the collection as > > > the indexed property type (because it's a valid indexed getter and the > > > iterate tags can use the collection to get their thing going). All you > > > need to do is wrap that collection directly. > > > > > > > > > For example, two complete beans... > > > > > > public class MonkeyBean { > > > public List getBananas() { return bananas; } > > > private List bananas = LazyCollections.lazyList(new ArrayList(), > > > BananaBean.class); > > > } > > > > > > public class BananaBean { > > > public String getFlavour() { return flav; } > > > public void setFlavour(String str) { flav = str; } > > > private String flav; > > > } > > > > > > > > > > > > The MonkeyBean is the parent class that hold the collection. It has > > > immediately wrapped the ArrayList in the LazyCollection, and passed it > > > the class of the BananaBean object. You may want to keep a reference to > > > the wrapped ArrayList, generally I don't have the need to. > > > > > > These classes are all but ready to rock. In the action class, query the > > > database or whatever and populate the MonkeyBean with the BananaBean > > > data. Serve the result to the JSP. > > > > > > JSP write out a list of text boxes using iterate tags. Submit this, and > > > after the monkeybean is built, the lazy collection will grow the banana > > > list with banana beans as the indexed requests come in. > > > > > > When it gets back to your action class, you'll have your collection of > > > banana beans. > > > > > > Hope this helps, you know where we are if it doesn't. > > > > > > > > > Arron. > > > > > > > > > > > > On Mon, 2002-07-22 at 22:59, hemant wrote: > > > > Comrades, > > > > > > > > > > > > Objective: To autopopulate forms on submit. The formbean "has a" > > collection of collections of ValueObjects. Each valueObject contains a pair > > of other Value Objects. > > > > > > > > Before people beat me up, The following possibilities have been dealt > > with: > > > > > > > > 1>> No, this is not a case of reset() I have the collections initialized > > and things are fine. > > > > > > > > 2>> It is not a case of bean being in request scope. By default the bean > > is in session scope (Unless we explicitly mention the action attribute that > > it is request scope.) > > > > > > [ ...cut...] > > > > > > > > > > > I am about to give up on form auto populate as I am out of time. I will > > be populating them by hand but anyway... one last attempt. We dont like to > > lose... do we? > > > > > > > > > > > > > > > > Thanks In Advance > > > > > > > > hemant > > > > > > > > > -- > > > To unsubscribe, e-mail: > > <mailto:[EMAIL PROTECTED]> > > > For additional commands, e-mail: > > <mailto:[EMAIL PROTECTED]> > > > > > > > > > -- > > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > > > > -- > To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> > For additional commands, e-mail: <mailto:[EMAIL PROTECTED]> > -- To unsubscribe, e-mail: < mailto:[EMAIL PROTECTED]> For additional commands, e-mail: < mailto:[EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>