personally i would map the form to a bean, and then in onsubmit()
transfer those properties to an instance of your domain object.

-igor


On Jan 20, 2008 7:54 AM, infodoc <[EMAIL PROTECTED]> wrote:
>
> Hello All,
>
> Have tried to search for this in the forums, but am not having much success
> due to the multiple concepts involved.  I apologize in advance for the long
> post.
>
> Question: is there a way to, after a Form has been submitted, create a new
> model object for that Form, based upon a value of a FormComponent within the
> Form, and then update that new Form model object with the values of the
> models of the other FormComponents in the Form??
>
> For example, I have a Account editor, used to both create and edit Accounts,
> which consists of a Form containing a number of FormComponents, eg., account
> name, date created, etc.  For the moment just consider the case of creating
> a new Account.  The Account constructor requires the email address of the
> person who is to be the admin of the Account.  Internally it converts that
> email address to a user object, saves that user to the db, and sets that
> user as admin of the Account.  Therefore, one of the FormComponents in the
> Account editor is a TextField whose model is the email address of the admin
> to provide to the Account constructor.  So far, so good.
>
> I have many editors like the one above for creating/editing other domain
> objects, and they work great.  For them I initially set the editor Form
> model object to a new instance of the type of object to be edited, and then
> update that model object using the models of the FormComponents in that
> respective editor.  I understand and am using a homegrown variant of
> ICompoundModel without problem.  Again, so far, so good.
>
> The problem: since the Account constructor requires the admin email address,
> and that address cannot be determined in advance, I cannot "pre-create" an
> Account to set as a blank model object to initialize the Account editor.  It
> is possible I could give a fake admin email address to the Account
> constructor, but that would create a fake user in the db, who would then
> have to be deleted - I would rather avoid that.
>
> What I had hoped to be able to do is: upon Form submission, get the admin
> email address from the TextField (in the Form) which handles that.  Create a
> NEW Account using that address (and handling any errors that occur).  Set
> the model object of the editor Form as that newly-created account.  Update
> that Form model object (new account) using the models of the other
> FormComponents, like I do successfully with my editors for other objects.
>
> I have read the docs and reviewed the source code - it seems I need to
> insert code to do the above in the chain of calls that flow from Form
> submission, after successful validation of FormComponents.  My question is,
> exactly where?  My best guess is override the editor Form's
> beforeUpdateFormComponentModels method, or perhaps the Form's
> updateFormComponentModels method, maybe even the process method?.  Inital
> attempts at this have been unsuccessful.
>
> Any and all suggestions/constructive criticism appreciated.  Thank you in
> advance for your time.
> --
> View this message in context: 
> http://www.nabble.com/create-new-model-object-of-a-Form-from-one-of-its-FormComp-values---tp14983110p14983110.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

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

Reply via email to