It sounds like that you might want to use the ModelDriven approach, where the AccountManager is the model object.
I was surprised to find that there doesn't seem to be a page or FAQ with regard to using ModelDriven. Essentially, all you need to do is place a model property on a base Action class, or at least the accessor. public Object getModel() ... In the implementation of getModel, acquire an instance of Account Manager object and return it. On the page, you can address any JavaBean properties on the AccountManager as if they were coded directly on the Action class. (The framework pushes the Model object onto the ValueStack.) Many developers use Spring to acquire something like the Account Manager. With the addition of a setModel method, the Action Manager can be injected automatically. HTH, Ted <http://www.husted.com/ted/blog/> On 4/5/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
Hello every one: I am trying to write a little application to familiarize myself with struts 2. I am trying to design the application using mvc2. the application is nothing but a small utility for invoices. It store, retrieves and update invoices. Each invoice belongs to an Account in the DB. from the examples I have seen so far, the Action class is populated by values from the jsp page. So here's my design: newAccount.jsp <------> AccountManager.java (ActionSupport) <----> Account.java veiwAccount.jsp Account.java is the class where all the bussiness logic goes. AccountManager is part of the controller and based on the results it gets from the Account.java it forwards to the appropriate view. The user can view an existing account or create one through the jsp pages. Now because it doesn't make scense to populate the AccountManager with getters/setters for the same fields in Account, I will pass Account as an attribute of the request to the view. I mean, if Account.java has fields , accountID, accountName , ... then I need getters and setters to access them, but the same getters and setters has to exist in AccountManager.java so that AccountManager can communicate with the views. However, I have read some where that because the bussiness logic may contain other resources ( ie, db connection, ..) we don't pass it to the view, but we pass a minimal verion of that class as a bean. So, I 'll create another class called ActionBean.java and populate it from within Account.java . PLease note that AccountManager can be accessed from many places and depending on the output it forwards to the correct view. I need an advice or comments, as I am new to struts 2 and MVC, and I feel that I am missing something. Can any one please correct me or give me comments?
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]