Hi,


>Arun,
>I think you can simplify this a little by accessing the PropertyDescriptor
>instead.
>If a form parameter from the HTML is "lastname" and there is a
>corresponding
>bean property called lastname
>with standard accessor methods of setLastname( String newlastname ) and
>getLastname() you can assign the
>form value as follows (with appropriate error checking etc):

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

Reply via email to