cancel
Showing results for 
Search instead for 
Did you mean: 

JavaBean Models, Command Bean and J2EE Design Pattern

Former Member
0 Kudos

Hello,

I have read the available "How To", “Using EJBs in Web Dynpro Applications” where the author mentions that one should use a Command Bean (according to J2EE Design Patterns) so that one can invoke business methods in a Session Bean from our Web Dynpro Application. Well, although, I have read some available articles in the internet about J2EE design patterns, I still have some questions about command beans and its usage in Web Dynpro applications.

I have developed a WD App which uses EJBs to read data from the DB.

Let's suppose I only have two tables: BOOKS and AUTHORS.

Let’s also suppose I have to Entity Beans (one for each table) and a Session Bean with two methods: Book[] getAllBooks() and Author[] getAllAuthors();

I also have a Command Bean which I imported in my WD App.

My questions are:

How should I design my Command Bean?

Can I have only one Command Bean with two methods each calling one of the methods of the Session Bean?

Or instead should I design two Command Beans, one for each call?

In the last case do the methods must be named <b>execute</b> or can I name them whatever I want?

Furthermore, how should I store the data in my command bean? In instance variables?

If so, can I use array of a class representing a record in the database table (for instance, classes Book and Author) or do I have to store the data in a generic collection (such as ArrayList for instance)?

I ask this last question because if I try to store the data in an array when I am importing the Command Bean as a JavaBean model I always get an error.

One last question: Can the Command Bean execute method directly return the data or should I always store the data in an instance variable an then get it using getter methods?

I know this questions are more about J2EE Design Patterns and JavaBeans specification than they are about Web Dynpro but I also have doubts about the rules that the command bean must obey in order to accomplish a successful JavaBean model import in WD.

Some guidance or tips would be highly appreciated.

King Regards

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

I have the same problem.

Does anyone know the solution?

Thanks

Davide

Former Member
0 Kudos

i have the same confusing...

who can help me?

Former Member
0 Kudos

Im also facing the same problem...if u get a solution please do let me know...

Thanks and Regards,

Sonal

Former Member
0 Kudos

Anyone?

Thanks