wood burning stoves 2.0*
The moose likes Struts and the fly likes Values in Struts JSP page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Values in Struts JSP page" Watch "Values in Struts JSP page" New topic
Author

Values in Struts JSP page

Anurag Mishra
Ranch Hand

Joined: Jun 16, 2003
Posts: 121
Hi,

I have a JSP page and I have a ActionClass which is called by controller(Action Servlet) when user select a option.

Now I am getting list of Users from a Stateless bean's method
getUserList(String Role) in say bean userBean.

Now I am getting the reference of userBean in my ActionClass and calling the
method getUserList(String Role) which returns me an arrayof User's and some of its properties in this way


Now if I want to Use these Roles (rolesList) in my JSP do I need to set the roleList in session and then only I can access in the JSP session.

Or is there some other way to do this.

thanks
Anurag


SCJP 1.2
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

There are a great number of ways to handle this. The best method depends on what that roleList is.
Do all users have the same list?,
How many pages/jsps need access to the list?,
etc.


A good workman is known by his tools.
Anurag Mishra
Ranch Hand

Joined: Jun 16, 2003
Posts: 121
there is
only one page which needs to handle the roleList.

And different Users will be having different Role lists.

I have one more question is there some other Place apart from ActionClass from where I can get the reference of my EJB and call the method??


thanks in Advance
Anurag Mishra
Ranch Hand

Joined: Jun 16, 2003
Posts: 121
hi all,

Please reply to this post.

thanks
Anurag
Kinjal Sonpal
Ranch Hand

Joined: Jun 06, 2003
Posts: 96
Originally posted by Anurag Mishra:
there is only one page which needs to handle the roleList. And different Users will be having different Role lists.


The most common approach, that I've seen so far, is to put the Array as an accessible property of the Form Bean. The population of this property would be done by the Action class. Since form bean instance would at most be in session scope, these lists would remain different per session/user.

I have one more question is there some other Place apart from ActionClass from where I can get the reference of my EJB and call the method??
Purists say that putting any logic which is even remotely related to business requirements, should not be part of the Action code. However, I found it too cumbersome to create one more layer/facade, since my application is really not massive. Most Actions in my code are implementing Sequence diagrams related to the UI logic.

HTH.

Thanks and Regards,
Kinjal Sonpal
Anurag Mishra
Ranch Hand

Joined: Jun 16, 2003
Posts: 121
Hi Kinjal,

Thanks for your reply
Can you Explain what you mean by
Most Actions in my code are implementing Sequence diagrams related to the UI logic.

Please just explain so I can implement this in an efficient way.

thanks in advance
Anurag
Kinjal Sonpal
Ranch Hand

Joined: Jun 06, 2003
Posts: 96
Originally posted by Anurag Mishra:
Can you Explain what you mean by
Most Actions in my code are implementing Sequence diagrams related to the UI logic.
Anurag, I'm sorry for ambigous statement like this.

A typical execute(or equivalent) method in an Action class of mine would have something like this :
Fetch validated user input from FormBean, construct VOs, push VOs thru' XyzManager for business processing(XyzManager will push data to the back-end by using XyzDataManager), fetch x or updated data from XyzManager, put them into the FormBean, forward to relevent mapping.

While designing the application, our (so-called) architect had develeloped several use-cases and corresponding sequence diagrams to explain the flow of data and control. At that time the decision to use struts was not in sight. These are the sequence diagrams that my Action classes are implementing.

I hope I'm being clearer here. I'm not having a very detailed understanding of Designing and architecting lingo and principles.

Let me know about your views.

Thanks and regards,
Kinjal Sonpal
[ June 04, 2004: Message edited by: Kinjal Sonpal ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Values in Struts JSP page