Thank you very Sven.

Here's what I've done for the 2nd solution (base on DefaultPropertyResolver)
:

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;

                // 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(lazyModel.getObjectClass(), fieldName);
        }
}

For the 1st solution I cannot overrides/extends LazyModel as its construtor
is private.
Also I'm not a reflection guru, so I'm a bit lost on how to get the getter
and setter from the LazyModel.
I need to provide those 3 methods :
-public Field getPropertyField();
-public Method getPropertyGetter();
-public Method getPropertySetter();

I've seen methods like "methodResolver.getSetter" and
"methodResolver.getMethod" in the StackIterator but have not found how to
use them...

Any help on this would be nice also :-).

Gabriel.






--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/wicketstuff-lazymodel-and-wicket-bean-validation-tp4660857p4660871.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to