Sorry, I meant populate, not persist - I don't want to confuse or mislead
anyone. It's been a long day... ;-) 

> -----Original Message-----
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On 
> Behalf Of Peter White
> Sent: Saturday, October 11, 2003 9:27 PM
> To: [EMAIL PROTECTED]
> Subject: RE: [OS-webwork] Need help with WW2 form processing...
> 
> Matt,
> 
> Thanks for the tip, it works like a charm! Now I have to 
> figure out the best way to adapt it to our situation but I'm 
> quite pleased to know that WW is able to persist a model 
> that's very similar to ours. 
> 
> Thanks again!
> Peter
> 
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED] 
> On Behalf Of 
> > Matt Ho
> > Sent: Friday, October 10, 2003 5:52 PM
> > To: [EMAIL PROTECTED]
> > Subject: Re: [OS-webwork] Need help with WW2 form processing...
> > 
> > I'm clearer now on what you're looking to do.  If
> > 
> > that[0].Cheetah.name
> > that[1].Monkey.name
> > 
> > works, then ModelDriven should work just fine.
> > 
> > Having said that, the following code snippet should work for you 
> > (haven't tested it though).  This is slightly different 
> than what you 
> > asked for in that what you end up with in animals is a list of 
> > AnimalHolders rather than animals.
> > 
> >      class MyAction implements ModelDriven {
> >          private List animals = new OgnlList(AnimalHolder.class);
> >          public Object getModel() { return this.animals ; }
> >          ...
> >      }
> > 
> >      class AnimalHolder {
> >          private AbstractAnimal animal;
> >          public AbstractAnimal getMonkey() throws Exception {
> >              return this.getAnimal(Monkey.class);
> >          }
> >          public AbstractAnimal getCheetah() throws Exception {
> >              return this.getAnimal(Cheetah.class);
> >          }
> >          public AbstractAnimal getAnimal(Class clazz) 
> throws Exception 
> > {
> >              if( this.animal == null ) {
> >                  this.animal = clazz.newInstance();
> >              }
> >              return this.animal;
> >          }
> >      }
> > 
> >      class OgnlList extends ArrayList {
> >          private Class clazz;
> > 
> >          public OgnlList(Class clazz) {
> >              this.clazz = clazz;
> >          }
> > 
> >          public synchronized Object get(int index) {
> >              while (index >= this.size()) {
> >                  try {
> >                      this.add(clazz.newInstance());
> >                  } catch (Exception e) {
> >                      throw new RuntimeException(e);
> >                  }
> >              }
> >              return super.get(index);
> >          }
> >      }
> > 
> > M
> > 
> > 
> > 
> > 
> > -------------------------------------------------------
> > This SF.net email is sponsored by: SF.net Giveback Program.
> > SourceForge.net hosts over 70,000 Open Source Projects.
> > See the people who have HELPED US provide better services:
> > Click here: http://sourceforge.net/supporters.php
> > _______________________________________________
> > Opensymphony-webwork mailing list
> > [EMAIL PROTECTED]
> > https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork
> > 
> 
> 
> 
> 
> -------------------------------------------------------
> This SF.net email is sponsored by: SF.net Giveback Program.
> SourceForge.net hosts over 70,000 Open Source Projects.
> See the people who have HELPED US provide better services:
> Click here: http://sourceforge.net/supporters.php
> _______________________________________________
> Opensymphony-webwork mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork
> 




-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
SourceForge.net hosts over 70,000 Open Source Projects.
See the people who have HELPED US provide better services:
Click here: http://sourceforge.net/supporters.php
_______________________________________________
Opensymphony-webwork mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/opensymphony-webwork

Reply via email to