You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by George Christman <gc...@cardaddy.com> on 2013/11/21 18:55:33 UTC
Custom Validator 5.4
Hello, I'm trying to build a custom validator but noticed some changes
regarding the js in 5.4. Does anybody know of a simple approach to handling
the js piece of the code?
javaScriptSupport.require("t5/core/validation");
writer.attributes(DataConstants.VALIDATION_ATTRIBUTE, true,
"data-validate-maxscale", constraintValue.toString(),
"data-maxscale-message", buildMessage(formatter, field,
constraintValue));
I'm not sure if I should be using coffee or what I'm suppose to be doing.
Thanks.
Re: Custom Validator 5.4
Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Thu, 21 Nov 2013 17:10:22 -0200, George Christman
<gc...@cardaddy.com> wrote:
> I was looking at the validator js on github
>
> https://github.com/apache/tapestry-5/blob/bb255c0a144a19939d357c0f071570eea272c918/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/validation.coffee
>
> but found myself lost in the coffee script. Now if I understand you
> correctly, when the fields are rendered, data- attributes are added to
> the fields and then used by my validation js?
Yep!
--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Custom Validator 5.4
Posted by George Christman <gc...@cardaddy.com>.
I was looking at the validator js on github
https://github.com/apache/tapestry-5/blob/bb255c0a144a19939d357c0f071570eea272c918/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/validation.coffee
but found myself lost in the coffee script. Now if I understand you
correctly, when the fields are rendered, data- attributes are added to the
fields and then used by my validation js?
Thanks Guys,
On Thu, Nov 21, 2013 at 1:53 PM, Thiago H de Paula Figueiredo <
thiagohp@gmail.com> wrote:
> On Thu, 21 Nov 2013 15:55:33 -0200, George Christman <
> gchristman@cardaddy.com> wrote:
>
> Hello, I'm trying to build a custom validator but noticed some changes
>> regarding the js in 5.4.
>>
>
> Does anybody know of a simple approach to handling the js piece of the
>> code?
>>
>> javaScriptSupport.require("t5/core/validation");
>> writer.attributes(DataConstants.VALIDATION_ATTRIBUTE, true,
>> "data-validate-maxscale", constraintValue.toString(),
>> "data-maxscale-message", buildMessage(formatter,
>> field, constraintValue));
>>
>
> I'm sorry, I'm not sure I know what you're asking. Anyway, just think that
> the data you need to perform the validation client-side now follows the way
> better approach of being located in data-* attributes instead of variables.
> Now just make your validation JavaScript code search for elements with the
> data-* attributes you're adding and add the validation hooks to them. Have
> you checked how the Tapestry validators are written? That's what I'd do
> until the documentation about it isn't available.
>
>
>
> I'm not sure if I should be using coffee or what I'm suppose to be doing.
>>
>
> You don't need to use CoffeeScript yourself.
>
> --
> Thiago H. de Paula Figueiredo
> Tapestry, Java and Hibernate consultant and developer
> http://machina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
--
George Christman
www.CarDaddy.com
P.O. Box 735
Johnstown, New York
Re: Custom Validator 5.4
Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Thu, 21 Nov 2013 15:55:33 -0200, George Christman
<gc...@cardaddy.com> wrote:
> Hello, I'm trying to build a custom validator but noticed some changes
> regarding the js in 5.4.
> Does anybody know of a simple approach to handling the js piece of the
> code?
>
> javaScriptSupport.require("t5/core/validation");
> writer.attributes(DataConstants.VALIDATION_ATTRIBUTE, true,
> "data-validate-maxscale", constraintValue.toString(),
> "data-maxscale-message", buildMessage(formatter,
> field, constraintValue));
I'm sorry, I'm not sure I know what you're asking. Anyway, just think that
the data you need to perform the validation client-side now follows the
way better approach of being located in data-* attributes instead of
variables. Now just make your validation JavaScript code search for
elements with the data-* attributes you're adding and add the validation
hooks to them. Have you checked how the Tapestry validators are written?
That's what I'd do until the documentation about it isn't available.
> I'm not sure if I should be using coffee or what I'm suppose to be doing.
You don't need to use CoffeeScript yourself.
--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Custom Validator 5.4
Posted by Chris Poulsen <ma...@nesluop.dk>.
coffeescript ends up as javascript in the end, so just give the javascript
version a go, if that is where you feel most comfortable.
These pages have also helped me get some t5.4 javascript going:
http://people.apache.org/~hlship/t5api/
On Thu, Nov 21, 2013 at 6:55 PM, George Christman
<gc...@cardaddy.com>wrote:
> Hello, I'm trying to build a custom validator but noticed some changes
> regarding the js in 5.4. Does anybody know of a simple approach to handling
> the js piece of the code?
>
> javaScriptSupport.require("t5/core/validation");
> writer.attributes(DataConstants.VALIDATION_ATTRIBUTE, true,
> "data-validate-maxscale", constraintValue.toString(),
> "data-maxscale-message", buildMessage(formatter, field,
> constraintValue));
>
> I'm not sure if I should be using coffee or what I'm suppose to be doing.
>
> Thanks.
>