Better use Bulk accessor...

1. Make a separate Data Class having all the fields with public access
    & make it Serializable bcoz It's tough to pass something around 30
    arguments to any other bean.

2. Don't provide any constructor, accessor & mutator. This seems to be
    far off than Java Coding Standard but believe me, when performance
    matters, then a method call is more costly than simply accessing the
    instance variable.

3. In JSP, make the data object, set the instance variables to valid values
&
    then pass it to bean.Bean will act on the data & update the DB. Results
    of that can be updated in the data object & then return this object back
to
    JSP for display. Don't unset the previous data. That can be useful
later.
    Here u need to take care of valid values bcoz u are not initializing the

    variables when u are constructing the object.

4. U need not package this class with the jar. Simply place it in the Server
's
    Classes directory.

I hope this can be the best solution....

Any other better soltion?????

-Davender Chhabra


> -----Original Message-----
> From: Mohit Jain [SMTP:[EMAIL PROTECTED]]
> Sent: Monday, August 07, 2000 9:20 PM
> To:   [EMAIL PROTECTED]
> Subject:      Design: multi-argument EB create method
>
> Hi Gurus,
>
> If I have a EB with say 15 persistent fields, how do I pass the data from
> my SessionBean to it?
>
> 1. pass all the fields as individual arguments on the create method call
> >> public BeanKey ejbCreate(String arg1, String arg2, String arg3..... ,
> String arg15) throws CreateException
>
> 2. pass the fields as a String array
> >> public BeanKey ejbCreate(String[ ] args) throws CreateException
>
> 3. use a "Bulk accessor" which would encapsulate all the Data elements:
> >> public class BeanData
> >> {
> >>   public String arg1;
> >>   public String arg2;
> >>   public String arg3;
> >>   ...
> >>   public String arg15;
> >>
> >>   public BeanData(String arg1, String arg2, String arg3.... , String
> arg15)
> >>   {
> >>        this.arg1 = arg1;
> >>        ...
> >>        this.arg15 = arg15;
> >>   }
> >>}
> Then my SessionBean can create a new instance of the BeanData object and
> pass it accross to the EB.
> Even if I use the Bulk accessor
>      a. should I use individual setter accessors to set data or should I
> pass all the values in the constructor??
>      b. how should the BeanData object be packaged, should it belong to
> the
> EntityBean component jar file or should it be placed on the
> application-server's serverclasses directory?
>      c. If the same data is coming all the way from the JSP, should the
> JSP
> also pass the data using the BeanData object to the SessionBean?
>
> Anyone has any recommendations?
> Regards
> Mohit
>
> ==========================================================================
> =
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
> body
> of the message "signoff EJB-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to