[Seaside] Where to put Magritte extension to ajax validate input fields

Gregor Schmidt seaside at schmidtwisser.de
Sat Jan 20 15:36:30 UTC 2007


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.


More information about the Seaside mailing list