Where to put Magritte extension to ajax validate input fields

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Where to put Magritte extension to ajax validate input fields

Gregor Schmidt-2
Hi everybody,

i wrote some code, that ajax validates Magritte definitions for form fields:

MATextInputComponent>>renderEditorOn:
        ...
        self hasScriptaculous ifTrue: [
                        textInput
                                onBlur: (html evaluator
                                                triggerFormElement:
textInput ensureId;
                                                callback: [ :script |
"self halt."
                                                                (self
description isSatisfiedBy: self string) ifFalse: [

         script element

                 id: textInput ensureId;

                 addClassName: 'error';

                 yourself.

 ] ifTrue: [

         script element

                 id: textInput ensureId;

                 removeClassName: 'error';

                 yourself.
                                                                        ].
                                                        ]).
                ]

which is currently placed in MATextInputComponent>>renderEditorOn:
which is in my opinion not the best place. One should be able to turn
of AjaxValidation on Forms, like one is able to do it with validation
on Forms:

(BlogPost new asComponent
        addValidatedForm;
        yourself).
vs.
(BlogPost new asComponent
        addForm;
        yourself).

So I would like to achieve something like
(BlogPost new asComponent
        addValidatedForm;
        addAjaxValidation;
        yourself).

Okay - the place for the addAjaxValidation Method is pretty clear -
MAContainerComponent - I guess. But how should the information to add
AjaxValidation reach the MATextInputComponent>>renderEditorOn: method?
Any help would be appreciated.

Best regards,

Gregor Schmidt

P.S.: Any suggestion on the pasted code are welcome. I am new to
Smalltalk/Seaside and sure this could look better. But the code works
as intended and is not the main issue of my question.
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Where to put Magritte extension to ajax validate input fields

Lukas Renggli
> Okay - the place for the addAjaxValidation Method is pretty clear -
> MAContainerComponent - I guess. But how should the information to add
> AjaxValidation reach the MATextInputComponent>>renderEditorOn: method?
> Any help would be appreciated.

I would create a completely new hierarchy. Like you have one for
Seaside and Morphic, one could imagine one for Scriptaculous. At least
this is what we did for a commercial project ...

Cheers,
Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
Seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside