>
> I always try to keep in mind that GWT is a tool kit. However, when a class 
> is named IntegerBox, to be used in a UI, yeah I expect it to be type safe 
> and also do what its name implies in the UI as well as programmatically. In 
> this case only allow Integers to be typed in.
>

Some years ago when doing ordinary desktop applications I would probably 
expect the same. But today developing web applications my mind shifted and 
I found it more important to be liberal on the user input but tell the user 
if they have done something wrong. This just feels more like things work on 
the web and I want to preserve this feeling even in web applications 
because thats what people are used to when using the web.
Also inexperienced users may think their keyboard is somehow broken if 
nothing happens when typing a letter into an input box because its just so 
uncommon on the web to swallow user input.


In any case, I'll hang on to this email and instead of talking more, 
> perhaps when I have some free time I'll just get to it and see if I can add 
> the implementation for it, test it across browsers and submit it for a 
> patch review. No promises since I am really busy these days, but we'll see.
>

Maybe it can be as easy as:

IntegerBox() {
 this(false); //makes sure that, by default, you get the same behavior as 
of today
}

IntegerBox(bolean strictMode) {
 super(Document.get().createInputElement(), IntegerRenderer.instance(), 
IntegerParser.instance(), strictMode ? IntegerInputValidator.instance() : 
null);
}

along with an additional constructor in ValueBox -> ValueBoxBase taking the 
input validator. If an input validator is present, ValueBoxBase attaches a 
key handler and routes key events through the validator (which can decide 
to swallow the key). That way you can opt-in to your desired behavior (you 
dont change behavior of existing apps) and you pretty much only have to 
implement input validators.

 

> Appreciate the responses.
>

You are welcome 

-- J.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/PG8WHFAnWBEJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to 
google-web-toolkit+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to