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
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