Well -- asking to use OgnlList is a problem since sometimes you don't have control over the objects.
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jason Carreira Sent: Thursday, January 08, 2004 9:10 AM To: [EMAIL PROTECTED] Subject: RE: [OS-webwork] how to populate a list of objects from a form I kind of like NOT supporting it in the NullHandler and suggesting the use of the OgnlList... Otherwise I would opt for putting it in the ActionName-properties file... And then convincing someone to build an Ant task (or Xdoclet extension) to generate these automatically... If you have: List items; List getItems(); void setItems(List aList); Item getItem(int index); void setItem(int index, Item item); It should be able to figure out that the type is Item... Maybe :-) > -----Original Message----- > From: Patrick Lightbody [mailto:[EMAIL PROTECTED] > Sent: Thursday, January 08, 2004 12:07 PM > To: [EMAIL PROTECTED] > Subject: RE: [OS-webwork] how to populate a list of objects > from a form > > > Paul, > Matt's solution is exactly what I want to put in generically > -- all I need to do is decinde on #1 or #2. Any feedback from > the users on this would be really helpful. > > -Pat > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On > Behalf Of Paul Knepper > Sent: Thursday, January 08, 2004 9:00 AM > To: [EMAIL PROTECTED] > Subject: RE: [OS-webwork] how to populate a list of objects > from a form > > See this post in the mail archive. > http://www.mail-archive.com/[EMAIL PROTECTED] > orge.net/m > sg05488.html > > Thanks to Matt Ho this solution worked great for me. I > didn't need to store different types of objects in my list so > I didn't need the holder class. > > In my action: > private List items = new OgnlList(Item.class); > > In my jsp: > <tr> > <input type="text" name="items[0].myProp1" /> > <input type="text" name="items[0].myProp2" /> > <input type="text" name="items[0].myProp3" /> > </tr> > <tr> > <input type="text" name="items[1].myProp1" /> > <input type="text" name="items[1].myProp2" /> > <input type="text" name="items[1].myProp3" /> > </tr> > > -Paul > > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] > Behalf Of Patrick Lightbody > Sent: Wednesday, January 07, 2004 8:31 PM > To: [EMAIL PROTECTED] > Subject: RE: [OS-webwork] how to populate a list of objects > from a form > > > Yes, but usually these types of grid input forms have N > number of rows, so pre-populating won't work. > > I'd like to take a quick vote on the two choices: > > 1) The domain model has a public static Class that > corresponds to each Collection, and so if we don't know what > type of object to create, we look for FOOS_TYPE or something > like that. The upside of this is that it is super easy to do > and isn't very surprising. The downside is that if you don't > have control of the objects (ie: codegen) then you're screwed. > > 2) Either in foo-conversion.properties or in another file > (foo-types.properties) there is a key-value pair of > property->Class. The upside is that this works for any > object, even ones you don't control. The downside is even > more optional configuration. > > Opinions? > > -Pat > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On > Behalf Of Jason Carreira > Sent: Wednesday, January 07, 2004 6:10 PM > To: [EMAIL PROTECTED] > Subject: RE: [OS-webwork] how to populate a list of objects > from a form > > I don't know about making an Interceptor for just one Action > :-) Just put it in the Action. > > If you know how many items you'll have you can pre-populate > the List with empty Item instances and use them... > > > -----Original Message----- > > From: Francisco Hernandez [mailto:[EMAIL PROTECTED] > > Sent: Wednesday, January 07, 2004 9:12 PM > > To: [EMAIL PROTECTED] > > Subject: Re: [OS-webwork] how to populate a list of objects > > from a form > > > > > > maybe you can use an Interceptor to do this for you on just > > that one action? > > > > Patrick Lightbody wrote: > > > > >Paul... yes and no (or, yes and not yet) :) > > > > > >Check out WebWork Tip #1 on my blog: > > > > > >http://www.lightbody.net/~plightbo/archives/000042.html > > > > > >Basically, we already support doing it if there was just a > > single Item > > >(or an array of Items), but when WW sees a List it currently > > has no way > > >to know it needs to do "list.add(new Item())". Any > suggestions as to > > >how you'd like to tell WW that the type of the list is > > "Item" would be > > >greatly appreciated. I originally thought of doing it in a hidden > > >field, but then that could pose a huge security problem. I > > also thought > > >of doing it in a properties file, but do we really want Yet Another > > >Property File? > > > > > > > > >Pat > > > > > >PS: I need more content for various WW tips. Please email me > > (plightbo > > >-at- yahoo -dot- com) privately with suggestions or ideas on > > topics I > > >should cover. > > > > > > > > >-----Original Message----- > > >From: [EMAIL PROTECTED] > > >[mailto:[EMAIL PROTECTED] On > > Behalf Of > > >Paul Knepper > > >Sent: Wednesday, January 07, 2004 10:59 AM > > >To: [EMAIL PROTECTED] > > >Subject: [OS-webwork] how to populate a list of objects from a form > > > > > >I would like to have WW2 populate a list of objects from a form. > > > > > >Say I have: > > > > > ><form> > > > <table> > > > <tr> > > > <input type="text" name="myProp1" /> > > > <input type="text" name="myProp2" /> > > > <input type="text" name="myProp3" /> > > > </tr> > > > > > > <tr> > > > <input type="text" name="myProp1" /> > > > <input type="text" name="myProp2" /> > > > <input type="text" name="myProp3" /> > > > </tr> > > > > > > <tr> > > > <input type="text" name="myProp1" /> > > > <input type="text" name="myProp2" /> > > > <input type="text" name="myProp3" /> > > > </tr> > > > </table> > > ></form> > > > > > > > > > > > >In my action class I have > > > > > >public MyAction extends ActionSupport { > > > private List itemsList = new ArrayList(); > > > > > >} > > > > > > > > >I also have a domain object class Item: > > >class Item { > > > private String myProp1; > > > private String myProp2; > > > private String myProp3; > > > > > > ... getters and setters > > >} > > > > > > > > >Is there a way to have WebWork2 populate the > > >itemsList List with instances of the Item > > >class populated from the data in the table? > > > > > >For each row in the table an instance of > > >the Item object should be inserted into the > > >itemsList property of the action class. > > > > > >Thanks, > > >Paul > > > > > > > > > > > >------------------------------------------------------- > > >This SF.net email is sponsored by: Perforce Software. > Perforce is the > > >Fast Software Configuration Management > > System offering > > >advanced branching capabilities and atomic changes on 50+ > platforms. > > >Free Eval! http://www.perforce.com/perforce/loadprog.html > > >_______________________________________________ > > >Opensymphony-webwork mailing list > > >[EMAIL PROTECTED] > > >https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork > > > > > > > > >------------------------------------------------------- > > >This SF.net email is sponsored by: Perforce Software. > Perforce is the > > >Fast Software Configuration Management > > System offering > > >advanced branching capabilities and atomic changes on 50+ > platforms. > > >Free Eval! http://www.perforce.com/perforce/loadprog.html > > >_______________________________________________ > > >Opensymphony-webwork mailing list > > >[EMAIL PROTECTED] > > >https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork > > > > > > > > > > > > > > > > > > > > > > > ------------------------------------------------------- > > This SF.net email is sponsored by: Perforce Software. > Perforce is the > > Fast Software Configuration Management System offering advanced > > branching capabilities and atomic changes on 50+ platforms. > Free Eval! > > http://www.perforce.com/perforce/loadprog.html > > > > _______________________________________________ > > Opensymphony-webwork mailing list > > [EMAIL PROTECTED] > > https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork > > > > > ------------------------------------------------------- > This SF.net email is sponsored by: Perforce Software. > Perforce is the Fast Software Configuration Management System offering > advanced branching capabilities and atomic changes on 50+ platforms. > Free Eval! http://www.perforce.com/perforce/loadprog.html > _______________________________________________ > Opensymphony-webwork mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork > > > ------------------------------------------------------- > This SF.net email is sponsored by: Perforce Software. > Perforce is the Fast Software Configuration Management System offering > advanced branching capabilities and atomic changes on 50+ platforms. > Free Eval! http://www.perforce.com/perforce/loadprog.html > _______________________________________________ > Opensymphony-webwork mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork > > > ------------------------------------------------------- > This SF.net email is sponsored by: Perforce Software. > Perforce is the Fast Software Configuration Management System offering > advanced branching capabilities and atomic changes on 50+ platforms. > Free Eval! http://www.perforce.com/perforce/loadprog.html > _______________________________________________ > Opensymphony-webwork mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork > > > ------------------------------------------------------- > This SF.net email is sponsored by: Perforce Software. > Perforce is the Fast Software Configuration Management System offering > advanced branching capabilities and atomic changes on 50+ platforms. > Free Eval! http://www.perforce.com/perforce/loadprog.html > _______________________________________________ > Opensymphony-webwork mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork > ------------------------------------------------------- This SF.net email is sponsored by: Perforce Software. Perforce is the Fast Software Configuration Management System offering advanced branching capabilities and atomic changes on 50+ platforms. Free Eval! http://www.perforce.com/perforce/loadprog.html _______________________________________________ Opensymphony-webwork mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork ------------------------------------------------------- This SF.net email is sponsored by: Perforce Software. Perforce is the Fast Software Configuration Management System offering advanced branching capabilities and atomic changes on 50+ platforms. Free Eval! http://www.perforce.com/perforce/loadprog.html _______________________________________________ Opensymphony-webwork mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork