Re: POJO Adapter in Wicket

2007-08-23 Thread Igor Vaynberg
i would use the pojos directly and put the presentation stuff into the model

-igor


On 8/23/07, Vincenzo Vitale <[EMAIL PROTECTED]> wrote:
>
> Hi All,
>
> I'm using Wicket (1.3.0 beta2), Hibernate and Spring.
>
> In my Wicket project for each POJO of my business model I created an
> Adapter maintaining the original object and having methods for the
> presentation layer (like getCompleteName()); I have not created a
> delegate getter or setter for all the properties of the target so in
> my wicket java code I simply bind the target properties with a name I
> choose.
> For example:
>
> final ApiAccountAdapter account = (ApiAccountAdapter) model.getObject();
> BoundCompoundPropertyModel accountModel = new
> BoundCompoundPropertyModel(account);
> TextField contactNameField = new TextField("contactName");
> accountModel.bind(contactNameField, "target.contactName");
>
>
> I use cascades with Hibernate to create/update my objects so the
> unique problems with the adapters approach is that I always want to
> use Adapters in the presentation projects and I always want to
> navigate my objects starting from the main object I'm using.
>
> So for example if I'm editing a parent object with a child list, in
> Wicket I need to create a ParentAdapter with a method like
> List getChildsList(); returning the List of adapters and
> I need to manually construct this method. If a child has also
> relations with other objects (directly or worst into Collections) the
> problem became rapidly really complex.
>
> Have you some suggestion on how to face in a better way the problem?
>
> My main requirements are:
>
> - I don't want to modify the POJOs adding presentation getters.
> - I want to use the dot notation in Wicket to easily access what I
> need: directly the pojo properties or some adapter (or whatever) with
> more complex getters.
> - When I have an input field in a page, representing a simple property
> in the main object or in some child object (like a property of a
> specific element of the child list) I don't want to manually map this
> field with the property of the object I want to be persisted. This
> work fine using adapters and mapping always an input field with
> target.property or a list with target.getListAdapter and then mapping
> the input fields in the list also with target.property.
>
> Sorry if I'm confusing you... :-)
>
>
> Thanks,
> Vicio.
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


POJO Adapter in Wicket

2007-08-23 Thread Vincenzo Vitale
Hi All,

I'm using Wicket (1.3.0 beta2), Hibernate and Spring.

In my Wicket project for each POJO of my business model I created an
Adapter maintaining the original object and having methods for the
presentation layer (like getCompleteName()); I have not created a
delegate getter or setter for all the properties of the target so in
my wicket java code I simply bind the target properties with a name I
choose.
For example:

final ApiAccountAdapter account = (ApiAccountAdapter) model.getObject();
BoundCompoundPropertyModel accountModel = new
BoundCompoundPropertyModel(account);
TextField contactNameField = new TextField("contactName");
accountModel.bind(contactNameField, "target.contactName");


I use cascades with Hibernate to create/update my objects so the
unique problems with the adapters approach is that I always want to
use Adapters in the presentation projects and I always want to
navigate my objects starting from the main object I'm using.

So for example if I'm editing a parent object with a child list, in
Wicket I need to create a ParentAdapter with a method like
List getChildsList(); returning the List of adapters and
I need to manually construct this method. If a child has also
relations with other objects (directly or worst into Collections) the
problem became rapidly really complex.

Have you some suggestion on how to face in a better way the problem?

My main requirements are:

- I don't want to modify the POJOs adding presentation getters.
- I want to use the dot notation in Wicket to easily access what I
need: directly the pojo properties or some adapter (or whatever) with
more complex getters.
- When I have an input field in a page, representing a simple property
in the main object or in some child object (like a property of a
specific element of the child list) I don't want to manually map this
field with the property of the object I want to be persisted. This
work fine using adapters and mapping always an input field with
target.property or a list with target.getListAdapter and then mapping
the input fields in the list also with target.property.

Sorry if I'm confusing you... :-)


Thanks,
Vicio.

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