[
https://issues.apache.org/jira/browse/WICKET-6383?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Sven Meier resolved WICKET-6383.
--------------------------------
Resolution: Invalid
Assignee: Sven Meier
Without a model object, PropertyModel is not able to provide information about
a properties field, getter or setter (specified in
IPropertyReflectionAwareModel).
Thus BeanValidationContext#resolveProperty() cannot resolve the bean property
and PropertyValidator fails.
You should make sure that your model can provide the required meta data, either
by setting the contained model object before any rendering is done (e.g. in
#onConfigure()) or by implementing IPropertyReflectionAwareModel in your model.
> PropertyValidator throws Exception when Model is empty
> ------------------------------------------------------
>
> Key: WICKET-6383
> URL: https://issues.apache.org/jira/browse/WICKET-6383
> Project: Wicket
> Issue Type: Bug
> Components: wicket-bean-validation
> Reporter: Kamil
> Assignee: Sven Meier
>
> During creation of PropertyValidator if Model is empty (it is set during
> runtime):
> {code}
> IModel<User> model = new Model<>();
> CompoundPropertyModel<User> compound = new
> CompoundPropertyModel<>(model);
> TextField<String> tf = new TextField<>("email",
> compound.bind("email"));
> tf.add(new PropertyValidator<>());
> add(tf);
> {code}
> an exception is thrown:
> {code}
> Last cause: Could not resolve Bean Property from component: [TextField
> [Component id = email]]. (Hints:) Possible causes are a typo in the
> PropertyExpression, a null reference or a model that does not work in
> combination with a IPropertyResolver. Model :
> Model:classname=[org.apache.wicket.model.PropertyModel]:nestedModel=[Model:classname=[org.apache.wicket.model.CompoundPropertyModel]:nestedModel=[Model:classname=[org.apache.wicket.model.Model]:object=[null]]]:expression=[email]
> WicketMessage: Error attaching this container for rendering: [UserPanel
> [Component id = formPanel]]
> {code}
> without this line:
> {code}
> tf.add(new PropertyValidator<>());
> {code}
> everything works
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)