[Seaside] Validating inputs before calling callback using AJAX serialization
Paul DeBruicker
pdebruic at gmail.com
Thu Jan 18 19:09:10 UTC 2018
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
> seaside at .squeakfoundation
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
--
Sent from: http://forum.world.st/Seaside-General-f86180.html
More information about the seaside
mailing list