When I use nested tags, I am not able to access it through java scripts since the name is "mailingAddress.city". Does anyone have a work around or am I missing something?
Jayaraman -----Original Message----- From: Craig R. McClanahan [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 13, 2002 12:23 PM To: Struts Users Mailing List Subject: Re: Re: Nested Tags question On Thu, 13 Jun 2002 [EMAIL PROTECTED] wrote: > Date: Thu, 13 Jun 2002 11:43:59 +0200 > From: [EMAIL PROTECTED] > Reply-To: Struts Users Mailing List <[EMAIL PROTECTED]> > To: Struts Users Mailing List <[EMAIL PROTECTED]> > Subject: Re: Re: Nested Tags question > > So Craig, > does the process work at submit time (when the request parameters are > being put into the nested beans) via calls to the getter methods to get > the beans on which the parameters have to be set? > > I can't see how else it would work. > It depends on what context you are using the expressions in. For example: <!-- Assume the form bean name is "customerForm" --> <html:form action="/editCustomer"> ... <html:text property="mailingAddress.city"/> ... </html:form> will, in effect, do a call to: customerForm.getMailingAddress().getCity() when the page is displayed, and a call to: customerForm.getMailingAddress().setCity() when the request parameters are being copied in to the form bean. > > Adam > Craig > > > "Craig R. McClanahan" <[EMAIL PROTECTED]> schrieb am 13.06.2002, > 08:22:43: > > > > > > On Thu, 13 Jun 2002, Arron Bates wrote: > > > > > Date: Thu, 13 Jun 2002 14:14:13 +1000 > > > From: Arron Bates > > > Reply-To: Struts Users Mailing List > > > To: Struts Users Mailing List > > > Subject: Re: Nested Tags question > > > > > > > > > > > > > > >I know JSP will automatically save parameters to a javabean with the > > > >correctly named getters and setters, but there's obviously a gap in my > > > >knowledge because all my attempts to recreate the situation above have > > > >failed. > > > > > > > > > > Setting form properties against beans is a Struts thing, not a JSP > > > thing. The property thing is a Bean thin and can be looked up in the > > > JavaBean spec. > > > > > > The example you quote... > > > > > > "monkeyTeamAlpha.monkeyWorkers[0].salary" > > > > > > ...is a nested property. An invention implemented within Struts > > > (Craig?). > > > > Yep, although in Struts 1.1 it is really a "commons-beanutils" thing > > because we abstracted out this generally useful code into a separate > > package. > > > > > What it basically is, is a string of calls rather than the > > > single property method. Here, it will get a hold of the form bean, get a > > > hold of the bean returned from the "monkeyTeamAlpha"property. On this > > > bean, it will invoke the indexed property "monkeyWorkers[0]" which will > > > pluck a bean from a collection or index provided, from this last bean it > > > will will get a hold of its "salary" property, and set the value. > > > > > > > At each stage, you also get the benefit of some intelligence that is built > > in to the underlying PropertyUtils class. For example, the JavaBeans spec > > defines two ways to define an indexed property -- you can use getter and > > setter methods that take a value and a subscript, or you can use getter > > and setter methods that return the entire array. PropertyUtils makes the > > expression listed above work for either (or even for a property whose > > value is a java.util.List, which is an extension to the JavaBeans spec). > > > > > All this boils down to, is that you can compose objects a little > > > cleaner, rather than have truly enormous beans for everything. Having > > > the indexed properties allows for lists and whatever else. > > > > > > The ability for nesting beans has been in Struts for a long time. The > > > nested tags just make it much easier. > > > > > > There's a primer and tutorial for nested beans here... > > > > > > http://www.keyboardmonkey.com/next > > > > > > ...it should take you over creating and using such a construct. > > > > > > Hope this gets you on th path you're after. > > > > Another area of useful learning for the future is the JSP Standard Tag > > Library (JSTL). Although the expression language syntax supported by JSTL > > is different from the one in Struts, it is well worth learning about -- > > this expression language will be supported anywhere in a JSP page in JSP > > 1.3, and (in the mean time) we will likely adapt Struts tags to be able to > > use it as well. > > > > > > > > > > > Arron. > > > > > > > Craig > > > > > > -- > > To unsubscribe, e-mail: > > For additional commands, e-mail: > > -- > 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]>