I feel like I am on the brink of understanding how to work with
these MVC components, but I am just not quite there yet.  Let me
present a scenario and then pose my question.

Assume I am working with financial accounts, such as bank accounts.
Each screen dealing with the accounts, whether it be to view a
report, a statement or a profile screen, will need to know several
things constantly:

- who is the current user?
- what accounts does this user have access to?
- what is the current selected account?

My hierarchy is as such

BaseAction -> BaseUserAction -> BaseAccountAction

in my actions, I have methods which store/load the user bean, the
list of cached accounts and the current account from session (so
that I don't have to continuosly look these things up).

Now comes the business delegate.  The business delegate obviously
can't know about my HTTP session, but it does help to pass the
session data into the delegate to save work each time.  Does it make
sense to set this information as private members of the delegate,
hence making it a bean?

public abstract AccountDelegate
{
    private List accounts;
    private User user;

    public void setAccounts(List accounts) {}
    public List getAccounts() {}

    public InvoiceReport getInvoiceReport(int accountNo, Date
    accountDate) {}

    public boolean isValidAccount(int accountNo) {}
}

This way, each time I run a method, such as getInvoiceReport, it
will first look in local members to find cached data, and then look
it up in the DAO if empty.  One check is to see whether the
accountNo provided is in the accounts list (the user has access).

It would help a great deal if this situation could be cleared up.
Please response with any followup questions.

Thanks!

Dan

-- 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
Daniel Allen, <[EMAIL PROTECTED]>
http://www.mojavelinux.com/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
Real programmers just hate to get up in the morning, and 
contrary to Ordinary People, they're in better shape as 
it gets closer to nighttime.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 


-------------------------------------------------------
SF.Net is sponsored by: Speed Start Your Linux Apps Now.
Build and deploy apps & Web services for Linux with
a free DVD software kit from IBM. Click Now!
http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click
_______________________________________________
Struts-apps mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/struts-apps

Reply via email to