[ 
https://issues.apache.org/jira/browse/TAPESTRY-2224?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12577423#action_12577423
 ] 

Andreas Andreou commented on TAPESTRY-2224:
-------------------------------------------

Dumping some of Numa's comments from the dev ML:

See my comments below of course these are suggestions :
They arrise when I tried to port some of my code from T4.0 to T4.1
and also when I tried to make old ValidField compatible with T4.1.
>
>     [ https://issues.apache.org/jira/browse/TAPESTRY-2224?
> page=com.atlassian.jira.plugin.system.issuetabpanels:comment-
> tabpanel&focusedCommentId=12574585#action_12574585 ]
>
> Andreas Andreou commented on TAPESTRY-2224:
> -------------------------------------------
>
> I see value in some of those suggestions... I guess the original
> thinking has been that you are
> able to hook on or rewrite every js part that you want, so, not
> many configuration options were given.
>
> I've never had to deal with 1,2,3 because i'd normally have a
> custom org.apache.tapestry.form.validatorValidator class
>  to implement the behavior and it would also call my custom
> javascript for (any needed) client-side checks
> Doing it this way, you dont have to deal with profiles, or where to
> attach your javascript, e.t.c.
Sometimes you just need a javascript function that validates the full
form and not only one field, and it needs to be only javascript and
custom java validation in form's listener because it might be
specific to only one particular form, so a Validator wouldn't be useful.
I think profiles are a kind of a pain, they are complicated and not
easy to understand (well at least for me).  When a validation error
occurs you have two cases :
a/ field is required
b/ field is invalid
That's all.  So we should be able to register messages to a stack or
list of messages for the form being validated and each message would
have a structure of this kind :
tapestry.form.error {
       isMissing : true,
       message : "field a is missing",
       field : myField
}
or
tapestry.form.error {
       isMissing : false,
       message : "field a should be a number",
       field : myField
}

You would append an error for a form the following way:

tapestry.invalid_field( myField, 'The field blah is invalid',
false) // the form is deducted from the myField
tapestry.invalid_field( myField, 'The field blah is required', true)


>
> For 4, tapestry.connect was meant for exactly that - connect to the
> tapestry namespace, because that's what
> all the internal code was doing... however, supporting the 4
> arguments version makes sense.
I Agree and it is simple to modify

To simplify hooking functions in the form submit, refresh, cancel
process; a function : tapestry.publish or tapestry.notify (ala dojo)
should exist
then we could connect a function to a form submit, refresh or cancel
process this way:

tapestry.connect(myForm, "onsubmit", "myFunction");

myFunction(event) {
       ......
       tapestry.event.stopEvent(event); //this should abort form submission
}

tapestry.submitAsync and tapestry.submit  would notify connected
functions (using tapestry.notify) and abort submission in case of
tapestry.event.stopEvent(event);


>
> For 5, you just need to redefine tapestry.form.summarizeErrors the
> way you want.
I agree but the problem is that you must understand the complicated
structure of form validation profiles to build the error message.
I think profiles shouldn't be so present... summarizeErrors should
only receive the form and a list of errors and nothing else.  The
list of errors should comply
with the error messages I defined previously.  So you just loop
through these messages.  And you can still overload the error message
structure with more stuff (like validation profiles)
 or overload the function summarizeErrors with a fourth argument ...

tapestry.form.summarizeErrors = function (myForm, myErrors) {

> Improve javascript archetype for form handling and validation
> -------------------------------------------------------------
>
>                 Key: TAPESTRY-2224
>                 URL: https://issues.apache.org/jira/browse/TAPESTRY-2224
>             Project: Tapestry
>          Issue Type: Improvement
>          Components: Core Components
>         Environment: MacosX
>            Reporter: Numa Schmeder
>            Assignee: Andreas Andreou
>             Fix For: 4.1.6
>
>
> Hello,
> After looking carefully at form.js and core.js.  There are problems with the 
> skeleton concerning form validation : 
> - There is no way to override or intercept a form submit event if the form is 
> submitted asynchronously, same for refresh or cancel ....
>    this is very much needed if you want a function to be notified when one of 
> this event happens
>    WETHER by tapestry.form.onsubmit("myForm", myFunction) OR 
> tapestry.connect("myForm", "onsubmit", myFunction)
> - There is no standard way to append a validation message to the stack of 
> validation messages created from the form profile.  
>   One should be able to call tapestry.invalid_field('The field blah is 
> invalid', isMissing ) And this should be appended to normal validation
> - Validation profiles are rather not clear, complicated and considered as 
> instable in the dojo tree, all the validation should not depend only on this 
> mechanism...
> - tapestry.connect assumes you connect a function in the tapestry namespace 
> !? that's wrong,  it should be :
>   For 3 args : search for the function in the tapestry namespace and global 
> namespace
>   For 4 args : search for the function in the given namespace
> - validation using tapestry should not impose its method to show JS 
> validation messages...  Actually it is a a dialog widget from dojo.   But it 
> should be made simple to override that with your own presentation function :
>  ex: tapestry.form.summarizeErrors(form, messages)
> Numa

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to