Re: zoning out on some basic LazyDynaMap usage for a text field property?
Thanks Martin, I'll have to look at this. For now I just went back to using the Session. My form was going to need to nest maps of maps to N levels. And the values that could be set for some of the maps could be a String[] or List[]. I got fed up trying to figure out how to get this to play nice using request scope. I'm going to look at how other frameworks (maybe even Struts2) handle these nested item issues with backing beans using Request scope. (I happen to be a fan of Stripes but haven't looked at how they manage this behind the scenes either because I'm swamped with work.) On Dec 2, 2007 11:59 AM, Martin Gainty <[EMAIL PROTECTED]> wrote: > > http://struts.apache.org/1.2.7/api/org/apache/struts/action/DynaActionForm.h > tml#initialize(org.apache.struts.action.ActionMapping)<http://struts.apache.org/1.2.7/api/org/apache/struts/action/DynaActionForm.html#initialize%28org.apache.struts.action.ActionMapping%29> > quote > Since Struts 1.1, the reset method no longer initializes property values > to > those specified in elements in the Struts module > configuration file. If you wish to utilize that behavior, the simplest > solution is to subclass DynaActionForm and call the initialize method > inside > it. > > 1)setup FormBeanConfig supplying name and type > > http://struts.apache.org/1.2.7/api/org/apache/struts/config/FormBeanConfig.h > tml > beanconfig.setName("name"); > and then beanConfig.setType("org.apache.struts.action.DynaActionForm"); > > 2)// Construct a corresponding DynaActionFormClass > > http://struts.apache.org/1.2.7/api/org/apache/struts/action/DynaActionFormCl > ass.html >dynaClass = new DynaActionFormClass(beanConfig); > constructing the DynaActionForm for FormBeanConfig class > > 3)2 ways to initialize DynaActionForm > Initialize your DynaActionForm is with FormBeanConfig if you have a > > of struts-config file > > http://struts.apache.org/1.2.7/api/org/apache/struts/action/DynaActionForm.h > tml#initialize(org.apache.struts.config.FormBeanConfig)<http://struts.apache.org/1.2.7/api/org/apache/struts/action/DynaActionForm.html#initialize%28org.apache.struts.config.FormBeanConfig%29> > > the other initialize method assumes you are initializing properties from > of struts-config file > > http://struts.apache.org/1.2.7/api/org/apache/struts/action/ActionMapping.ht > ml > > complete example located at > /src/test/org/apache/struts/action/TestDynaActionFormClass.java > > M-- > - Original Message ----- > From: "Vinny" <[EMAIL PROTECTED]> > To: "Struts Users Mailing List" > Sent: Friday, November 30, 2007 8:57 PM > Subject: Re: zoning out on some basic LazyDynaMap usage for a text field > property? > > > > Hmm, > > I've never tried using lazy inside a standard ActionForm, the ones that > I > > have work inside of > > a DynaValidatorActionFom (say that 3 times fast). Don't feel like > writing > a > > reset method? you are > > getting old Rick. > > > > On Nov 30, 2007 7:17 PM, Rick Reumann <[EMAIL PROTECTED]> wrote: > > > > > I swore I used to be able to do this stuff... maybe it's Friday thing, > but > > > regardless I'm blanking on out on what I'm doing wrong with this... > > > > > > I have an ActionForm that has one property right now: > > > private LazyDynaBean dynaBean = new LazyDynaMap(); > > > > > > My goal is to be able to populate this DynaBean with any level of > nested > > > DynaMaps and have everything populate correctly using Request scope on > my > > > form. (Not shown here but an 'answer' as a map value can end up being > > > another Map and so on - nested to any level.) > > > > > > I'm currently having trouble defining the property name correctly. > Here > is > > > a > > > summary > > > > > > Not working: > > > > > > > > > Error: > > > Invalid argument looking up property: > > > "dynaBean.map(question_1).map(answerString)" > > > of bean: "myForm" > > > > > > Working fine: > > > > > questionAnswer.set("answerString", "Fido"); > > > map1.put("question_1", questionAnswer); > > > > > > > > > I've tried a few different ways defining the text field property all > with > > > no > > > luck at the moment. What am I doing wrong? (I know I could also use a > > > DynaActionForm defined in my struts-config, but this should work as > well > > > with a DynaBean in a standard ActionForm. I typically don't like using > > > DynaActionForm because I end up usually having to create a reset > method > > > anyway so once I do that I might as well code the properties in that > > > concrete class.) > > > > > > -- > > > Rick > > > > > > > > > > > -- > > The Street Programmer http://streetprogrammer.com > > > > > - > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Rick
Re: zoning out on some basic LazyDynaMap usage for a text field property?
http://struts.apache.org/1.2.7/api/org/apache/struts/action/DynaActionForm.h tml#initialize(org.apache.struts.action.ActionMapping) quote Since Struts 1.1, the reset method no longer initializes property values to those specified in elements in the Struts module configuration file. If you wish to utilize that behavior, the simplest solution is to subclass DynaActionForm and call the initialize method inside it. 1)setup FormBeanConfig supplying name and type http://struts.apache.org/1.2.7/api/org/apache/struts/config/FormBeanConfig.h tml beanconfig.setName("name"); and then beanConfig.setType("org.apache.struts.action.DynaActionForm"); 2)// Construct a corresponding DynaActionFormClass http://struts.apache.org/1.2.7/api/org/apache/struts/action/DynaActionFormCl ass.html dynaClass = new DynaActionFormClass(beanConfig); constructing the DynaActionForm for FormBeanConfig class 3)2 ways to initialize DynaActionForm Initialize your DynaActionForm is with FormBeanConfig if you have a of struts-config file http://struts.apache.org/1.2.7/api/org/apache/struts/action/DynaActionForm.h tml#initialize(org.apache.struts.config.FormBeanConfig) the other initialize method assumes you are initializing properties from of struts-config file http://struts.apache.org/1.2.7/api/org/apache/struts/action/ActionMapping.ht ml complete example located at /src/test/org/apache/struts/action/TestDynaActionFormClass.java M-- - Original Message - From: "Vinny" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" Sent: Friday, November 30, 2007 8:57 PM Subject: Re: zoning out on some basic LazyDynaMap usage for a text field property? > Hmm, > I've never tried using lazy inside a standard ActionForm, the ones that I > have work inside of > a DynaValidatorActionFom (say that 3 times fast). Don't feel like writing a > reset method? you are > getting old Rick. > > On Nov 30, 2007 7:17 PM, Rick Reumann <[EMAIL PROTECTED]> wrote: > > > I swore I used to be able to do this stuff... maybe it's Friday thing, but > > regardless I'm blanking on out on what I'm doing wrong with this... > > > > I have an ActionForm that has one property right now: > > private LazyDynaBean dynaBean = new LazyDynaMap(); > > > > My goal is to be able to populate this DynaBean with any level of nested > > DynaMaps and have everything populate correctly using Request scope on my > > form. (Not shown here but an 'answer' as a map value can end up being > > another Map and so on - nested to any level.) > > > > I'm currently having trouble defining the property name correctly. Here is > > a > > summary > > > > Not working: > > > > > > Error: > > Invalid argument looking up property: > > "dynaBean.map(question_1).map(answerString)" > > of bean: "myForm" > > > > Working fine: > > > questionAnswer.set("answerString", "Fido"); > > map1.put("question_1", questionAnswer); > > > > > > I've tried a few different ways defining the text field property all with > > no > > luck at the moment. What am I doing wrong? (I know I could also use a > > DynaActionForm defined in my struts-config, but this should work as well > > with a DynaBean in a standard ActionForm. I typically don't like using > > DynaActionForm because I end up usually having to create a reset method > > anyway so once I do that I might as well code the properties in that > > concrete class.) > > > > -- > > Rick > > > > > > -- > The Street Programmer http://streetprogrammer.com > - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: zoning out on some basic LazyDynaMap usage for a text field property?
On Nov 30, 2007 8:57 PM, Vinny <[EMAIL PROTECTED]> wrote: > Hmm, > I've never tried using lazy inside a standard ActionForm, the ones that I > have work inside of > a DynaValidatorActionFom (say that 3 times fast). Don't feel like writing > a > reset method? Unless I'm missing something, the reset method would have to know how deep to the initialization (which it won't know for a request scoped form that can be nested to N levels.) Typically I'd take the approach shown about half way down here: http://wiki.apache.org/struts/StrutsCatalogLazyList where I'd decorate using ListUtils in my reset method, but that only works when you know how deep you need to initialize things. Maybe I'll just try out a DynaActionForm.. still using a DynaBean inside of a regular ActionForm I'd think should work (assuming you populate all your nested items with LazyDyna beans. At least I think it should. I'll have to mess around more with it. I just want to be able to populate a nested set of maps to any level that will work with request scope. At this point, I don't even care about using standard pojos in my maps so dynabeans will be fine if it makes things easier.
Re: zoning out on some basic LazyDynaMap usage for a text field property?
Hmm, I've never tried using lazy inside a standard ActionForm, the ones that I have work inside of a DynaValidatorActionFom (say that 3 times fast). Don't feel like writing a reset method? you are getting old Rick. On Nov 30, 2007 7:17 PM, Rick Reumann <[EMAIL PROTECTED]> wrote: > I swore I used to be able to do this stuff... maybe it's Friday thing, but > regardless I'm blanking on out on what I'm doing wrong with this... > > I have an ActionForm that has one property right now: > private LazyDynaBean dynaBean = new LazyDynaMap(); > > My goal is to be able to populate this DynaBean with any level of nested > DynaMaps and have everything populate correctly using Request scope on my > form. (Not shown here but an 'answer' as a map value can end up being > another Map and so on - nested to any level.) > > I'm currently having trouble defining the property name correctly. Here is > a > summary > > Not working: > > > Error: > Invalid argument looking up property: > "dynaBean.map(question_1).map(answerString)" > of bean: "myForm" > > Working fine: > questionAnswer.set("answerString", "Fido"); > map1.put("question_1", questionAnswer); > > > I've tried a few different ways defining the text field property all with > no > luck at the moment. What am I doing wrong? (I know I could also use a > DynaActionForm defined in my struts-config, but this should work as well > with a DynaBean in a standard ActionForm. I typically don't like using > DynaActionForm because I end up usually having to create a reset method > anyway so once I do that I might as well code the properties in that > concrete class.) > > -- > Rick > -- The Street Programmer http://streetprogrammer.com
zoning out on some basic LazyDynaMap usage for a text field property?
I swore I used to be able to do this stuff... maybe it's Friday thing, but regardless I'm blanking on out on what I'm doing wrong with this... I have an ActionForm that has one property right now: private LazyDynaBean dynaBean = new LazyDynaMap(); My goal is to be able to populate this DynaBean with any level of nested DynaMaps and have everything populate correctly using Request scope on my form. (Not shown here but an 'answer' as a map value can end up being another Map and so on - nested to any level.) I'm currently having trouble defining the property name correctly. Here is a summary Not working: Error: Invalid argument looking up property: "dynaBean.map(question_1).map(answerString)" of bean: "myForm" Working fine: