I am designing a simple order system which will allow a user to view current orders and to add or delete orders from their account. I would like to run this past the experienced users of this forum and get feedback on whether or not I am thinking straight, or if I should take a different approach. This is my first time designing a Struts application, and using EJBs, so I am a bit unsure of whether or not I'm going about this in the right way. My plan is to have Struts Actions call stateless session beans to perform actions such as authenticating users, getting user preferences, getting current orders, and adding/modifying/deleting orders from the system. As an example of my thinking below is a use case and my current ideas on how to tackle it. The use case is a user logging in to the system, and upon successful authentication having a new page display the user profile information (name, organization, etc.) and a list of pending orders. I plan to have a Struts Action class (LoginAction) mapped to the action of the JSP login form. The LoginAction will lookup a session bean which will have a business method to authenticate the user against a LDAP server or database of users. If the authentication succeeds then the LoginAction will call another business method of the session bean to find the user's profile and preferences information as an entity bean (via findByPrimaryKey()), and get a collection of entity beans which will represent the orders. So now there will be one entity bean with the user profile information and a collection of entity beans which represent the user's orders. This is the point where I am very unsure of things, assuming the above is the correct approach in the first place. How do I maintain control of these beans -- do I add the component interface references to the user's session as attributes ? Or do I want to get the beans' handles and store these in the session ? The session bean will get the profile entity bean and the collection of order entity beans and pass them out as return values to the LoginAction class, but will they still be present on the server for use once the LoginAction completes and passes control on to the next JSP page ? Since they're entity beans they're not tied to any one user's session (right ?), so how will a JSP or another Action class know how to access these unless they are tied to the user's session as attributes ? How do I access these beans on the JSP page that I redirect to once the orders and profile are found -- is it as simple as just using <jsp:useBean> ? Another consideration is how do I deal with the collection of entity beans on the JSP page ? What I mean is that I want to go through the collection of entity beans which make up the orders and print the order items on the page in a table, something like "for each order bean in the collection of order beans print order id, order item, order amount, order price, etc.". It doesn't appear that there are any facilities for doing this sort of processing of collections of beans, in that you only have jsp:useBean at your disposal, and this is for single beans, not collections of beans.
Any feedback will be greatly appreciated, thanks in advance for sharing your knowledge and expertise.
catch it before it slithers away! Oh wait, it's a tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop