> I think you can simplify this a little by accessing the
> PropertyDescriptor instead.
I just realized that one problem with using PropertyDescriptors
is that they require matched get/set pairs for the property.
This isn't a big deal, but everyonce in a while, I do have properties
that I want to set based on the request which don't necessarily have
matching getters.
In response to the message below, it seems to me that, while it does
appear to be entirely safe to use a static method, an equivalent possibility
would be to implement the propogate method as an instance method of a
common action superclass. Just an alternative, though again, I can't
see anything wrong with using a static method in this case.
-AMT
> -----Original Message-----
> From: A mailing list about Java Server Pages specification and reference
> [mailto:[EMAIL PROTECTED]]On Behalf Of Kevin Duffey
> Sent: Tuesday, April 11, 2000 2:17 PM
> To: [EMAIL PROTECTED]
> Subject: Re: Bean reflection (was More on Model 2/little confused)
<SNIP>
> EXACTLY!! This is what we have in mind now. What we want to do is what
> Craig/Daniel are doing, using XML to load up a page that describes each
> action name, class and forwarding urls. Each action class is passed the
> request object which would create a bean, and populate it. Right
> now I have
> a bunch of setXXX(request.getParameter("XXX")); However..this is
> tedious. I
> have one of two solutions. The one you proposed, and exactly what you
> proposed but a single static method that does this for all bean instances.
> First..is it BAD to use a static method (or final class) for this purpose?
> The reason is, I don't want to have to repeat the looping and refelction
> code in every single Action class to populate every specific bean instance
> with the request parameters. I figured if I could create a single
> class/method static and final, it would speed things up, and
> since the only
> variables are those passed in to the method, it would be thread
> safe as well
> (parameters are put on to the stack of each thread right?). Thus,
> something
> like:
>
> public final class BeanPropogate
> {
> public static final propogate(Object o, HttpServletRequest r)
> {
> // get request parameter names
> // loop through all names
> // using reflection, check if the object passed in has a setXXX method
> that matches each
> name from the request parameter list of names
> // if so, call it passing to it the request parameter value
> of the name
> // if not, ignore it.
> }
> }
>
>
> Is something like above good? I think this is what the JSP engine does for
> Model 1 JSP/JavaBean use when setProperty="*" is used. Seems to
> me the best
> way to do this..but like I said, I would rather use a single
> method for ALL
> action classes so as not to keep repeating code.
>
> Let me know what you think?
>
> ==================================================================
> =========
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
> JSP-INTEREST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
> http://java.sun.com/products/jsp/faq.html
> http://www.esperanto.org.nz/jsp/jspfaq.html
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
> http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets
>
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets