Thank you.  Exactly what I was looking for.

Cheers,



On Fri, Sep 18, 2009 at 9:42 PM, Chad <[email protected]> wrote:
>
> dk,
>
> There are a few ways you can accomplish this. One way to do it is to
> use inner classes to handle your events:
>
> public class MyCoolWidget {
>  private class DateHandler implements ValueChangeHandler<Date> {
>    public void onFailure(Throwable caught) { ... }
>    public void onSuccess(ValueChangeEvent<Date> event) { ... }
>  }
>  private class StringHandler implements ValueChangeHandler<String> {
>    public void onFailure(Throwable caught) { ... }
>    public void onSuccess(ValueChangeEvent<String> event) { ... }
>  }
> }
>
> Then, when you add the value change handlers, instead of passing the
> this object reference, you pass either new DateHandler() or new
> StringHandler().
>
> Another way would be to use anonymous inner classes:
>
> myDateControl.addHandler(new ValueChangeHandler<Date>() {
>  public onFailure(Throwable caught) { ... }
>  public onSuccess(ValueChangeEvent<Date> event) { ... }
> });
>
> It just depends on if your preference and how many times you'd need to
> add them.
>
> You could probably also just implement the ValueChangeHandler
> generically without the type at your class level. You'd probably need
> to suppress the unchecked warning. Then, you'd have one onFailure
> method and one onSuccess method. The difference is that your onSuccess
> will received an Object and you'd have to check for the type of
> instance and cast it as necessary. I know that works with
> AsyncCallbacks, but I've never tried it with ValueChangeHandlers.
>
> HTH,
> Chad
>
> On Sep 18, 4:00 pm, dk <[email protected]> wrote:
>> Ok, I am back to not knowing what I am doing.  Before I wrote the last
>> note I am sure there were no warnings/errors on what I was doing but I
>> have the Can not implement ValueChange with different types message
>> again.
>>
>> ideas are welcome
> >
>



-- 
Dean Karres

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to