Hi everyone !! Since this morning, I have some problems with the FieldValidatorSourceImpl. In fact, I would like to override it, by using the ClientId of the field instead of the Tapestry ID for the keys of the messages (the error message and the constraint). For doing that, I decorated this service, and change the signature of the public FieldValidator createValidator(Field field, String validatorType, String constraintValue, String overrideId, Messages overrideMessages, Locale locale) method by using my delegate object.
public FieldValidatorSource decorateFieldValidatorSource(final FieldValidatorSource delegate) { return new FieldValidatorSource() { public FieldValidator createValidators(Field field, String specification) { return delegate.createValidators(field, specification); } public FieldValidator createValidator(Field field, String validatorType, String constraintValue, String overrideId, Messages overrideMessages, Locale locale) { return delegate.createValidator(field, validatorType, constraintValue, field.getClientId(), , overrideMessages, locale); } public FieldValidator createValidator(Field field, String validatorType, String constraintValue) { return delegate.createValidator(field, validatorType, constraintValue); } }; } But, this delegate is just called for validator defined with the @Validate annotation. For the t:validate binding, using the createValidators of the same service, my decorator is not called. Is it normal ? Or Do I forgot something ? I have also tested with an advise, and the problem is the same : @Match("FieldValidatorSource") public static void adviseValidator(MethodAdviceReceiver receiver) throws SecurityException, NoSuchMethodException{ MethodAdvice advise = new MethodAdvice() { public void advise(Invocation invocation) { Field field = (Field) invocation.getParameter(0); invocation.override(3, field.getClientId()); invocation.proceed(); } }; receiver.adviseMethod(receiver.getInterface().getMethod("createValidator", Field.class, String.class, String.class, String.class, Messages.class, Locale.class),advise); } So I succeeded by using the ServiceOverride, copy/paste the default implementation and change the overrideId by field.getClientId(): public static void bind(ServiceBinder binder) { binder.bind(FieldValidatorSource.class, MyFieldValidatorSourceImpl.class).withId("MyFieldValidatorSourceImpl"); } @Contribute(ServiceOverride.class) public static void setupApplicationServiceOverrides(MappedConfiguration<Class,Object> configuration, @Local FieldValidatorSource override) { configuration.add(FieldValidatorSource.class, override); } But the problem is that the Validator Configuration (defined in the TapestryModule) object is now empty ! If I had my own contribution for my service it works. Is it normal ? How can I use the Configuration object of the default implementation ? public static void contributeMyFieldValidatorSourceImpl(MappedConfiguration<String, Validator> configuration) { configuration.add("required", new Required()); configuration.add("minlength", new MinLength()); configuration.add("maxlength", new MaxLength()); configuration.add("min", new Min()); configuration.add("max", new Max()); configuration.add("regexp", new Regexp()); configuration.add("email", new Email()); configuration.add("none", new None()); } Thanks a lot. Manu -- View this message in context: http://tapestry.1045711.n5.nabble.com/Overriding-Decorating-Advising-FieldValidatorSource-tp5714093.html Sent from the Tapestry - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org