You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Nathan Quirynen <na...@pensionarchitects.be> on 2016/12/01 11:27:23 UTC
Custom validator default error message
Hi,
I have a Tapestry module contributing some custom validator
implementations. How can i set default validation error messages for
these in Tapestry 5.4?
In older Tapestry versions I think you had to contribute a message
catalog to the ValidationMessagesSource service, but this does not exist
in Tapestry 5.4.
Nathan
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Custom validator default error message
Posted by Nathan Quirynen <na...@pensionarchitects.be>.
Hmm, I don't need a custom validator annotation.
Example:
I just created a class that extends AbstractValidator and contributed
this to the FieldValidatorSource in my module:
public class MaxBigDecimal extends
AbstractValidator<BigDecimal,BigDecimal> {
private static final String MESSAGE_KEY = "max-bigdecimal";
public MaxBigDecimal(JavaScriptSupport javaScriptSupport) {
super(BigDecimal.class, BigDecimal.class, MESSAGE_KEY,
javaScriptSupport);
}
...
}
This way I can add the validator using the @Validate annotation or
validate parameter:
@Validate("required, max-bigdecimal=1")
This all works fine, I can even set the message in my page/component for
a field with id "fldRate" by setting the following in the message catalog:
fldRate-max-bigdecimal-message=Some error message
But if I don't "override" this like above it says " [[missing key:
max-bigdecimal]]". So I just want to be able to set this default error
message in the module contributing this validator. Normally I would have
to add a ValidationMessages.properties file containing
"max-bigdecimal=Some default error message" and contribute this file to
the ValidationMessagesSource service. But this service does not exist
anymore in 5.4 and just adding the file also doesn't seem to do anything.
Or should I now go with the custom validator annotation way as in your
example to get it all working?
Nathan
On 01/12/16 13:13, JumpStart wrote:
> Does this help?
>
> http://jumpstart.doublenegative.com.au/jumpstart7/examples/input/contributingvalidators <http://jumpstart.doublenegative.com.au/jumpstart7/examples/input/contributingvalidators>
>
> Cheers,
>
> Geoff
>
>> On 1 Dec 2016, at 7:27 PM, Nathan Quirynen <na...@pensionarchitects.be> wrote:
>>
>> Hi,
>>
>> I have a Tapestry module contributing some custom validator implementations. How can i set default validation error messages for these in Tapestry 5.4?
>>
>> In older Tapestry versions I think you had to contribute a message catalog to the ValidationMessagesSource service, but this does not exist in Tapestry 5.4.
>>
>> Nathan
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Custom validator default error message
Posted by JumpStart <ge...@gmail.com>.
Does this help?
http://jumpstart.doublenegative.com.au/jumpstart7/examples/input/contributingvalidators <http://jumpstart.doublenegative.com.au/jumpstart7/examples/input/contributingvalidators>
Cheers,
Geoff
> On 1 Dec 2016, at 7:27 PM, Nathan Quirynen <na...@pensionarchitects.be> wrote:
>
> Hi,
>
> I have a Tapestry module contributing some custom validator implementations. How can i set default validation error messages for these in Tapestry 5.4?
>
> In older Tapestry versions I think you had to contribute a message catalog to the ValidationMessagesSource service, but this does not exist in Tapestry 5.4.
>
> Nathan
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>