Re: Immediate validation of editor field

2012-10-09 Thread RickL
Thomas,

Thank you, as always, for your thoughtful reply.  I wonder how you get any 
real work done with your dedication to this forum.  I suspect you get a bit 
less sleep than me.  

The flush technique works fine.  I even managed to craft a little editor 
visitor that passes a flush command to editors that want it (those that 
implement HasFlushCommand) so that they can request a driver flush (on a 
value change) without knowing anything about the driver.  With that, I can 
have generic UiBinder-compatible validating editors that are capable of 
displaying immediate errors, like:

e:ValueBoxEditorDecorator ui:field=priorityEditor 
  e:valuebox
v:ValidatingIntegerBox ui:field=priorityValidator /  !-- so that 
the app can set properties (min, max, immediate or whatever) --
  /e:valuebox
/e:ValueBoxEditorDecorator

I don't think it strays too much from the spirit of the editor framework.

Thanks again.


On Monday, October 8, 2012 9:33:33 AM UTC-5, Thomas Broyer wrote:



 On Monday, October 8, 2012 3:56:57 PM UTC+2, RickL wrote:

 There is a workaround, but it is not very elegant.  You can do a 
 driver.flush() in a change handler for the field you want to validate 
 on-the-fly which, of course, re-validates (i.e. calls getValue()) on all 
 fields.  That seems to me a bit like swatting a fly with a sledgehammer.

 It would seem better to have, perhaps, another recordError method 
 signature like:

 void recordError(String message, Object value, Object userData, boolean 
 immediate);

 When immediate is true, the driver would immediately post the error to 
 the nearest super-Editor that implements the HasEditorErrors interface, 
 rather than waiting for a driver flush().

 Thoughts?



 Don't try to abuse the Editor framework for use-cases it's not meant to 
 fulfill. What you actually want is some widget that validate the field as 
 soon as possible and displays the error if any, *and* integrate with the 
 Editor framework so that any detected error will also be reported to the 
 EditorDelegate.
 Either that or flush() at each change.


-- 
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/-/LiYLAskwY7MJ.
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.



Re: Immediate validation of editor field

2012-10-08 Thread RickL
I found the solution.  I was using an editor decorator to wrap the 
number validating editor.  In this case it appears that you must forward 
the setDelegate from the editor decorator to its sub-editor as in:

  @Override
  public void setDelegate(EditorDelegateT delegate) {
if (editor instanceof HasEditorDelegate) {
  ((HasEditorDelegateT) editor).setDelegate(delegate);
}
  }

It works now.

On Sunday, October 7, 2012 3:38:05 PM UTC-5, RickL wrote:

 I have a problem.  I want to force the editor framework to immediately 
 validate a field when the user changes its value.  The most obvious and 
 simple case is a numeric field.  If the user enters an invalid number, I 
 want the error to be reported as soon as the user leaves the field.  I 
 don't want to wait for the user to initiate a save to detect that error 
 (and other errors like it that don't need to go to the server).

 This seems like it should be very easy, but I sure can't seem to find a 
 clean solution.

 Thanks




-- 
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/-/qPXu3Bahj0UJ.
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.



Re: Immediate validation of editor field

2012-10-08 Thread RickL
Actually, that only fixed part of my problem: the fact that the editor was 
not reporting errors at all (because it was not getting a delegate).  I 
still do not have a good solution to the original question.

Sorry about the confusion.

On Monday, October 8, 2012 7:40:29 AM UTC-5, RickL wrote:

 I found the solution.  I was using an editor decorator to wrap the 
 number validating editor.  In this case it appears that you must forward 
 the setDelegate from the editor decorator to its sub-editor as in:

   @Override
   public void setDelegate(EditorDelegateT delegate) {
 if (editor instanceof HasEditorDelegate) {
   ((HasEditorDelegateT) editor).setDelegate(delegate);
 }
   }

 It works now.

 On Sunday, October 7, 2012 3:38:05 PM UTC-5, RickL wrote:

 I have a problem.  I want to force the editor framework to immediately 
 validate a field when the user changes its value.  The most obvious and 
 simple case is a numeric field.  If the user enters an invalid number, I 
 want the error to be reported as soon as the user leaves the field.  I 
 don't want to wait for the user to initiate a save to detect that error 
 (and other errors like it that don't need to go to the server).

 This seems like it should be very easy, but I sure can't seem to find a 
 clean solution.

 Thanks




-- 
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/-/0oz1Jz5vY0gJ.
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.



Re: Immediate validation of editor field

2012-10-08 Thread RickL
There is a workaround, but it is not very elegant.  You can do a 
driver.flush() in a change handler for the field you want to validate 
on-the-fly which, of course, re-validates (i.e. calls getValue()) on all 
fields.  That seems to me a bit like swatting a fly with a sledgehammer.

It would seem better to have, perhaps, another recordError method signature 
like:

void recordError(String message, Object value, Object userData, boolean 
immediate);

When immediate is true, the driver would immediately post the error to the 
nearest super-Editor that implements the HasEditorErrors interface, rather 
than waiting for a driver flush().

Thoughts?


On Monday, October 8, 2012 7:44:28 AM UTC-5, RickL wrote:

 Actually, that only fixed part of my problem: the fact that the editor was 
 not reporting errors at all (because it was not getting a delegate).  I 
 still do not have a good solution to the original question.

 Sorry about the confusion.

 On Monday, October 8, 2012 7:40:29 AM UTC-5, RickL wrote:

 I found the solution.  I was using an editor decorator to wrap the 
 number validating editor.  In this case it appears that you must forward 
 the setDelegate from the editor decorator to its sub-editor as in:

   @Override
   public void setDelegate(EditorDelegateT delegate) {
 if (editor instanceof HasEditorDelegate) {
   ((HasEditorDelegateT) editor).setDelegate(delegate);
 }
   }

 It works now.

 On Sunday, October 7, 2012 3:38:05 PM UTC-5, RickL wrote:

 I have a problem.  I want to force the editor framework to immediately 
 validate a field when the user changes its value.  The most obvious and 
 simple case is a numeric field.  If the user enters an invalid number, I 
 want the error to be reported as soon as the user leaves the field.  I 
 don't want to wait for the user to initiate a save to detect that error 
 (and other errors like it that don't need to go to the server).

 This seems like it should be very easy, but I sure can't seem to find a 
 clean solution.

 Thanks




-- 
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/-/xEx-hLKW0xUJ.
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.



Re: Immediate validation of editor field

2012-10-08 Thread Thomas Broyer


On Monday, October 8, 2012 3:56:57 PM UTC+2, RickL wrote:

 There is a workaround, but it is not very elegant.  You can do a 
 driver.flush() in a change handler for the field you want to validate 
 on-the-fly which, of course, re-validates (i.e. calls getValue()) on all 
 fields.  That seems to me a bit like swatting a fly with a sledgehammer.

 It would seem better to have, perhaps, another recordError method 
 signature like:

 void recordError(String message, Object value, Object userData, boolean 
 immediate);

 When immediate is true, the driver would immediately post the error to the 
 nearest super-Editor that implements the HasEditorErrors interface, rather 
 than waiting for a driver flush().

 Thoughts?



Don't try to abuse the Editor framework for use-cases it's not meant to 
fulfill. What you actually want is some widget that validate the field as 
soon as possible and displays the error if any, *and* integrate with the 
Editor framework so that any detected error will also be reported to the 
EditorDelegate.
Either that or flush() at each change.

-- 
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/-/QUZvSMTHLVIJ.
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.



Immediate validation of editor field

2012-10-07 Thread RickL
I have a problem.  I want to force the editor framework to immediately 
validate a field when the user changes its value.  The most obvious and 
simple case is a numeric field.  If the user enters an invalid number, I 
want the error to be reported as soon as the user leaves the field.  I 
don't want to wait for the user to initiate a save to detect that error 
(and other errors like it that don't need to go to the server).

This seems like it should be very easy, but I sure can't seem to find a 
clean solution.

Thanks


-- 
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/-/0qRe3dLImwQJ.
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.