[Seaside] Best way to guarantee a textInput will be a positive
johan at inceptive.be
Tue Oct 26 19:07:13 UTC 2010
If you want to verify the input at the server-side when the form is submitted, here's roughly what it would look like (writing this off the top of my head):
callback:[:val | [theInteger := val asInteger] on: Error do:[:e | anError := <do whatever you want> ]];
Essentially, you must catch the error inside the callback itself (or inside a method called from within the callback). When the callback is evaluated, the render method in which the callback is statically located is not on the execution stack.
When Seaside has finished executing the callback, it will (automatically) restart the render loop for your application. At that point, you can decide to render the error message, display the form again, or anything else you want to do.
Also, in Pharo pre 1.2 and (presumably) in Squeak, this conversion will not throw an error if 'val' is not an integer. Instead, it will return nil. So, the actual code in the callback might differ depending on the platform you are using.
I hope this answers your question
On 26 Oct 2010, at 17:00, Gilles Schtickzelle wrote:
> Hello again,
> I have a form where some of the input field should only be filled with integer values. I try to test the value in the setter and throw an error when it's not an integer but I can't figure out how to catch the error in the renderContentOn method of my component, and something tells me it's not the correct way to do this.
> Is there something like "integerInput" that would force an integer value instead of a textInput?
> Gilles _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
More information about the seaside