David Hecksel wrote:

> I'm designing a set of beans to allow bean calls within a JSP page.  The
> bean instance has many attributes/properties.  So - what's the best way
> to design bean methods - pass in many parameters for the action method
> to work off of, or rely on setter methods prior to invoking the bean
> action method
>
> Ie - is it better to do:
>
> <% mybean.doaction(" param1 param2 param3 ... "); %>
>

I assume you would make these actual parameters, right?  Something like:

    <% mybean.doaction("param1", "param2", "param3"); %>

>
> or better to do:
>
> <% mybean.setParam1("param1"); %>
> <% mybean.setParam2("param2"); %>
> ....
> <% mybean.setParam("paramn"); %>
> <% bean.doaction(); %>
>
> What's the "best practice" or suggested practice for doing something
> like this?
>

I would make a choice between these approaches by following the usual
JavaBeans design principles -- the fact that you are accessing the bean
from a JSP page is not relevant to that choice.  In particular, if the
parameter values should persist past the current call, I would make them
properties using setXxx methods.  If they are simply transient arguments to
the doaction() procedure and do not need to be saved for later, I would
make them arguments.

>
> Thanks for the feedback - I know Java well, but am still learning with
> respect to beans and JSP.
>
> Dave Hecksel
> Axtive Software Corporation
> (214) 880-4820
>

Craig McClanahan

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to