On 9/21/05, Koen Jans <[EMAIL PROTECTED]> wrote:
> Here's my problem;
>
> A user has several accounts, represented by AccountBean objects, all
> having a unique accountId.
>
> Now, i have a form where the user can select one of his accounts to edit
> through a radio button selection. For the associated ActionForm, i see
> two options to represent the selected account;
>
> 1) on my ActionForm;  a property "int selectedAccountId"
> 2) on my ActionForm;  a property "AccountBean selectedAccount"
>
> The first option seems good because it preserves the philosophy that an
> ActionForm represents the user's input..
>
> The second is nice because the edit-Action, associated with the form,
> can immediately extract the selectedAccount from the ActionForm, whereas
> using the first approach, a database call is needed to retrieve the
> selected account again by the account's id.
>
> Which option would you prefer, and especially why? Thanks for your time

I would prefer option (2) but I don't see how it can save on database
call. A user can have several accounts. Do you want to select all of
them into a list or array before displaying a form?

* I would put reference to AccountBean in the form and set it to null
* When a user selects account, I would load the account into detached
bean, and point reference to it
* If needed I would create delegate setters in the form which verify
the state of the action before allowing to change bean's value
* If editing is canceled, reference to detached bean is nullified
* Oh, and I use session scope to keep nested properties between requests

Michael.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to