Re: Validating inputs before calling callback using AJAX serialization

Paul DeBruicker <[email protected]>
Newsgroups gmane.comp.lang.smalltalk.squeak.seaside
Message-ID <[email protected]>
In your Seaside callback: could you do a

html anchor
    callback:[:val | self validateWith: [:v | self validateOutsideInput: v]
thenExecute: [:v | self myOriginalCallbackMethods: v] for: val]


and 

validateWith: validationBlock thenExecute: callbackBlock for: submittedValue
   (validationBlock cull: submittedValue) ifTrue:[callbackBlock cull:
submittedValue]


?

I don't really understand what happens when callbacks are executed from the
seaside perspective that would want you to keep it from executing.  The pile
of stuff I don't understand grows daily though :)

Hope this helps


Paul




Esteban A. Maringolo wrote
> 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





--
Sent from: http://forum.world.st/Seaside-General-f86180.html
_______________________________________________
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.