Validating inputs before calling callback using AJAX serialization

"Esteban A. Maringolo" <[email protected]>
Newsgroups gmane.comp.lang.smalltalk.squeak.seaside
Message-ID <CAJMgPCLKJre=a3VaLtpA7r+-GHfD_XqU1chyBowbX+Ebvnd8hQ@mail.gmail.com>
Hi all,

I'm trying to find a clean and "proper" way of dealing with the validation
of user entered values in forms _before_ they hit the callback block.

And based on such validation result be able to respond one script or
another.

Let's say I have something like

html textInput
  onChange: (html jQuery ajax serializeThis);
  script: (html jQuery script: [:s | "fancy things that modify the web UI"
];
  callback: [:value | self doSomethingWithValue: value]

The problems with that are:
a) I can't "sanitize" the input before it reaches the callback block, I
have to do it within the callback block.
b) I have no way to return one script for a successful validation, and one
for a failing one.

I'd like something like

A)
html textInput
  onChange: (html jQuery ajax
    serializeThisValidating: validationBlock
    successScript:  [:s | "fancy things that modify the web UI" ]
    failureScript:  [:s | "modify the web UI reporting the failure" ]);
  callback: [:value | self doSomethingWithValue: value]

or...
B)
html textInput
  onChange: (html jQuery ajax serializeThis);
  callback: [:value | self doSomethingWithValue: value ]
  validation: aBlock
  successScript: [:s | "fancy things that modify the web UI" ]
  failureScript:   [:s | "modify the web UI reporting the failure" ].


I think that the A option is the best alternative, since all the "special
handling" will happen in the context of the JQAjax and maybe a special kind
of JSAjaxCallback).

Also I don't know how this would work in the context of _several_ validated
callbacks, but I plan to make it work in the context of #serializeThis only.

But I'm sure there is a simpler way of achieving this, since I tend to make
things complicated.

Any suggestions?


Esteban A. Maringolo

_______________________________________________
seaside mailing list
[email protected]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.