I am writing a banking application where the user has multiple accounts. In the user's session, I need the concept of the currently selected account. The account selection can be changed on any page - sometimes by clicking a row in a data table and at other times by selecting an account from a drop down list. What is the best way to implement this?
Currently I have an account list page that uses a data table to select an account:
@Name("accountListController")
@Scope(ScopeType.CONVERSATION)
public class AccountListController implements Serializable {
@DataModel(scope=ScopeType.PAGE)
private List<Account> accounts;
@DataModelSelection
@Out(required=false)
private Account selectedAccount;
}
All other pages use a drop down to select an account. For example:
@Name("paymentController")
@Scope(ScopeType.CONVERSATION)
public class PaymentController implements Serializable {
@Out(required=false)
private List<Account> accounts;
private Account selectedAccount;
As you can see, here selectedAccount is not the same as the selectedAccount outjected by the AccountListController? Is there a way to factor out selectedAccount into a separate session-scoped variable and used by multiple components?
Thanks.
Naresh