How does Wicket load an object and combine it with a user's web input? (newbie question)

2008-05-16 Thread David Wicket
I just started learning Wicket. I have some experience with JSP+Spring.
In Spring, based on a hidden id parameter from a form, I can use 
formBackingObject method to load the object. Spring combines a user's 
input in the form with the loaded object to form the latest version of this 
object and then I can save it.
I am not sure how to do the same thing in Wicket. I tried 
and I got errors.
In addition, how to let Wicket combine user input with the old version object 
loaded from the database?
Any pointers, examples, explanation?
Thanks you so much for your help!!!
Regards. input wicket:id=id type=hidden/


  

Re: How does Wicket load an object and combine it with a user's web input? (newbie question)

2008-05-16 Thread Maurice Marrink
You do not need a hidden form parameter, wicket automatically resolves
the form input with the component on the server side.
On submit the model of the component is loaded and set with the new
input. If you use a model such as LoadableDetachableModel, that knows
how to get the latest object from the database then the object is thus
updated and can be saved.
For example
Form form=new Form(form, new
CompoundPropertyModel(myLoadableDetachableUserModel))
form.add(new TextField(firstName);
form.add(new TextField(LastName);

We use a LoadableDetachableModel to get the user from the database on
each request.
We wrap it in a CompoundPropertyModel so we can then easy use other
components to set its fields.
Because we use a CompoundPropertyModel we do not have to specify
models for the textfields, instead the id of the textfields is used to
resolve the getter and setter on the user object.

For a more in depth example you should check out
http://www.theserverside.com/tt/articles/content/IntroducingApacheWicket/article.html
or one of the other tutorials floating around

Maurice

On Fri, May 16, 2008 at 11:59 AM, David Wicket [EMAIL PROTECTED] wrote:
 I just started learning Wicket. I have some experience with JSP+Spring.
 In Spring, based on a hidden id parameter from a form, I can use 
 formBackingObject method to load the object. Spring combines a user's input 
 in the form with the loaded object to form the latest version of this object 
 and then I can save it.
 I am not sure how to do the same thing in Wicket. I tried 
 and I got errors.
 In addition, how to let Wicket combine user input with the old version object 
 loaded from the database?
 Any pointers, examples, explanation?
 Thanks you so much for your help!!!
 Regards. input wicket:id=id type=hidden/




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