Hi Gabriel,
LazyModel implements IPropertyReflectionAwareModel now, so integration
with beanvalidation should work out-of-the-box with the next release.
Best regards
Sven
On 08/13/2013 09:40 PM, Gabriel Landon wrote:
The previous code was flawed. Here's the right one!
It's far from perfect but as I'm using only IObjectClassAwareModel models
it's working!
public class LazyModelPropertyResolver implements IPropertyResolver {
@Override
public Property resolveProperty(final FormComponent<?> component) {
IModel<?> model = component.getModel();
while (true) {
if (model == null) {
return null;
}
if (model instanceof LazyModel<?>) {
break;
}
if (model instanceof IWrapModel<?>) {
model = ((IWrapModel<?>)
model).getWrappedModel();
continue;
}
return null;
}
final LazyModel<?> lazyModel = (LazyModel<?>) model;
//I'm using only IObjectClassAwareModel
if (lazyModel.getTarget() instanceof IObjectClassAwareModel) {
// le nom de la propritĂ© (qui peut ĂȘtre dans une chaine
du genre
"foo.bar.baz").
String fieldName = lazyModel.getPath();
if (fieldName.contains(".")) {
fieldName = StringUtils.substringAfterLast(fieldName,
"."); // on prend
le dernier champ
}
return new Property(((IObjectClassAwareModel<?>)
lazyModel.getTarget()).getObjectClass(), fieldName);
}
return null;
}
}
--
View this message in context:
http://apache-wicket.1842946.n4.nabble.com/wicketstuff-lazymodel-and-wicket-bean-validation-tp4660857p4660872.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
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org