I'll try to give some quick help.  Ask again if you have more detailed
questions.

On Mon, Jun 28, 2010 at 8:04 AM, Marzia Forli <marzia.fo...@yahoo.com>wrote:

> I have a problem with IModel's... Right now I am doing my homework with
> 'Wicket In Action' and I know that models are connections to a data...
> What I need to know if there is some kind of design pattern/advice about
> handling the models...
> For example there are some typical scenarios that appear in the apps'
> 1) login form with some ILoginService which have: login (String username,
> String password) and returns User. Would I have to have user and password
> Strings as Form attributes or something else ?
>

Something like this can be done with a regular Model for each of the Strings
- the default implementation of IModel.  It simply holds a serializable
value.  Or, you can have two String properties in your SignInForm class
(which is probably a panel containing a form), and then give the TextFields
each an instance of PropertyModel that connects it to those properties on
the form class.


> 2) user profile data which are in db
>

A LoadableDetachableModel should be in charge of loading these domain
objects from the database.


> 3) detail of shopping cart
>

Again, probably a LoadableDetachableModel.  It depends on where you're
storing it.  You will likely store this in the Session (remember that the
session is not thread safe by default).  But, you may be storing it to the
DB so that it outlives the session.  Your call.


-- 
Jeremy Thomerson
http://www.wickettraining.com

Reply via email to