Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

A different event is triggered after the optionality check; The memo.translated property is the value translated before validation (for a numeric field, it would be translated from a string to a number, for example). Again, the error property is set, and the return false ensures that the event will stop bubbling to containing elements or event handlers.

What's very useful in this overall approach is that it no longer matters whether the fields were rendered by Tapestry on the server, or rendered locally (perhaps using Backbone or AngularJS) on the client. As long as they have the correct data- attributes, then they can participate in Tapestry's overall form validation and submission cycle, and even leverage the default validation decoration behavior.

The Abstraction Layer

The abstraction layer is defined by the t5/core/dom module. This module is two different implementations - one is a wrapper around Prototype, and the other is a wrapper around jQuery.

The result is a a bit schizophrenic; it mostly looks like jQuery, but events look a bit more like jQuery. It also doesn't have jQuery's concept of a matched set of elements.

The abstraction is both transitional and permanent. It is transitional in that it is about allowing existing sites with a heavy investment in Prototype to continue to operate with Prototype in the mix. It is permanent in that it is desirable to keep an abstraction layer between Tapestry's client-side code and any underlying framework, so that particular applications can provide their own abstraction layer and operate without breaking built-in components.

Most applications should transition to jQuery and feel free to use jQuery directly.  It is still best to inject module jquery into your own modules (usually as parameter $). 

If you are writing a third-party application and want to maximize re-use, then use the abstraction.

It is often easier to use the abstraction to respond correctly to