You could overwrite the FieldValidatorSource and the
FieldValidatorImpl, which is responsible for creating validator
instances, so that it .

Or you use this hack in your Validator. It uses the message object of
the current field:

public void validate(Field aField, Integer aConstraintValue,
MessageFormatter aFormatter, Collection selectedItems)
    throws ValidationException {
    Component comp = (Component)aField;
    Messages messages = comp.getComponentResources().getMessages();
    ...
}

Cheers


2012/4/23 sub <b4679...@nwldx.com>:
> Hi,
>
> I have a custom validator:
>
> public class MyPasswordValidator extends AbstractValidator<Void, String>
>
> and I want to use my default messages for user output. I already tried:
>
> @Inject
> private Messages messages;
>
> But its always null and doesn't work in my validator. So I will use the
> constructor:
>
> public MyPasswordValidator(Messages messages) {
>    this.messages = messages;
> }
>
> And now I am stuck here:
>
> AppModule.java
>
> public static void
> contributeFieldValidatorSource(MappedConfiguration<String,
> Validator&lt;?,?>> configuration) {
>    configuration.add("myPassword", new MyPasswordValidator(???));
> }
>
> Where do I get the message resource? I couldn't find any example on this.
>
> Thx
> sub
>
>
>
>
> --
> View this message in context: 
> http://tapestry.1045711.n5.nabble.com/How-to-use-messages-without-Inject-tp5658897p5658897.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
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to