Re: Reusable form fields ... the proper way disucssion

2014-12-16 Thread armandoxxx
thank you ... 
regards 

Armando

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Reusable-form-fields-the-proper-way-disucssion-tp4668783p4668800.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Reusable form fields ... the proper way disucssion

2014-12-16 Thread Martin Grigorov
Hi,

Using a Panel should be fine.
Using PropertyModel is also fine.
Assuming there is a CompoundPropertyModel(Person) and Person object has an
Address, and Address has a Street then you should do:

mainModel = new CompoundPropertyModel(new Person());
form = new Form(formId, mainModel);
form.add(new AddressPanel(addressPanelId, new PropertyModel(mainModel,
"address")))

AddressPanel may have a TextField for the Street:
add(new TextField("street"))

or use a random tree structure and use the addressPanel's model:
anIntermediateContainer.add(new TextField("str", new
PropertyModel(AddressPanel.this.getModel(), "street") ))


Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Tue, Dec 16, 2014 at 1:44 AM, armandoxxx 
wrote:
>
> Hey guys
>
> I would like to know to properly do this in wicket.
>
> I have form fields that I would like to use in several forms ...
>
> lets say I want a model object for a
> SearchFields {country, language}  << properties in brackets
> and then I extend it with
> UserSearchFields {userTags}
> and
> CustomerSearchFields {customerTags}
> and put it into models ...
> 1. Model.of()
> 2. new PropertyModel(new {onOfTheseExtendedObjects}(), "{propertyName}");
> 3. new CompoundPropertyModel(new {onOfTheseExtendedObjects}())
>
> so I create Common component with fields for country and language, then I
> create separate components for UserTagsComponent (with userTags field) and
> CustomerTagsComponent (with customerTags field).
>
> I create different forms:
> UserForm  which adds model of new UserSearchFields object and both Common
> and UserTagsComponent components .
> CustomerForm which adds model of new CustomerSearchFields object and both
> Common and CustomerTagsComponent.
>
> my questions are:
> 1. what component to use to wrap fields to reuse them and add them to form?
> I tried FormComponentPanel but my model (CompoundPropertyModel) object did
> not include the FormComponentPanel name property; for exmaple:
> "searchFields", so I changed my panel with fields to ordinary Panel (then
> using my CompoundPropertyModel worked as expected)
> 2. what model implementation to use so Form would understand the fields in
> sub components... I tried PropertyModel ... but I had a problem when I
> called setDefaultModelObject(new CustomerSearchFields()) on my form ...
> values were not set.
>
> I read reference and wicket book .. I understand how model implementations
> work .. I'm just not sure how to make it work properly If I use sub
> components for common fields ...
>
> regards
>
> Armando
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/Reusable-form-fields-the-proper-way-disucssion-tp4668783.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


Reusable form fields ... the proper way disucssion

2014-12-15 Thread armandoxxx
Hey guys

I would like to know to properly do this in wicket. 

I have form fields that I would like to use in several forms ... 

lets say I want a model object for a 
SearchFields {country, language}  << properties in brackets
and then I extend it with 
UserSearchFields {userTags}
and
CustomerSearchFields {customerTags}
and put it into models ... 
1. Model.of()
2. new PropertyModel(new {onOfTheseExtendedObjects}(), "{propertyName}");
3. new CompoundPropertyModel(new {onOfTheseExtendedObjects}())

so I create Common component with fields for country and language, then I
create separate components for UserTagsComponent (with userTags field) and
CustomerTagsComponent (with customerTags field). 

I create different forms:
UserForm  which adds model of new UserSearchFields object and both Common
and UserTagsComponent components .
CustomerForm which adds model of new CustomerSearchFields object and both
Common and CustomerTagsComponent.

my questions are:
1. what component to use to wrap fields to reuse them and add them to form? 
I tried FormComponentPanel but my model (CompoundPropertyModel) object did
not include the FormComponentPanel name property; for exmaple:
"searchFields", so I changed my panel with fields to ordinary Panel (then
using my CompoundPropertyModel worked as expected)
2. what model implementation to use so Form would understand the fields in
sub components... I tried PropertyModel ... but I had a problem when I
called setDefaultModelObject(new CustomerSearchFields()) on my form ...
values were not set. 

I read reference and wicket book .. I understand how model implementations
work .. I'm just not sure how to make it work properly If I use sub
components for common fields ... 

regards

Armando


 














--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Reusable-form-fields-the-proper-way-disucssion-tp4668783.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org