As much as I prefer teaching men how to fish to throwing fish at them,
mostly because fish are delicious, I think I'll chuck one out now.

ClickHandler myFirstHandler = new ClickHandler() {... stuff ...};
ClickHandler mySecondHandler = new ClickHandler() {... stuff ...};

Button pressMePlease = new Button("OMGWTF");

pressMePlease.addClickHandler(myFirstHandler);
pressMePlease.addClickHandler(mySecondHandler );
... etc

In general, I have found subclassing UI elements to lead down the road
to fiery ruin, which is far worse than normal ruin because of the
burning and all.  Adding handlers (of all kinds, not just
ClickHandlers) to the UI elements instead seems to be a much more sane
way of managing events, and allows you to put your view behind an
interface, so your application logic is separate, testable, and way
prettier.  And as programmers, we should be all about the pretty.

-Ben

On Jan 14, 11:45 am, Vik <[email protected]> wrote:
> Hie
>
> Any example how to do that please?
>
> Thankx and Regards
>
> Vik
> Founderwww.sakshum.comwww.sakshum.blogspot.com
>
> On Fri, Jan 14, 2011 at 8:54 PM, Tej <[email protected]> wrote:
> > how about firing two separate events? and have independent handlers
> > for them?
>
> > On Jan 14, 3:48 pm, Vik <[email protected]> wrote:
> > > Hie
>
> > > I have an address component which is a vertical panel with state,
> > district,
> > > city and area  and a search button.
>
> > > In two different situations, I have to fire different code on click of
> > > search button.
>
> > > So, is there a generic way to deal with this instead of writing in the
> > > onClick  of button if(case1) else case2 thing ?
>
> > > Thankx and Regards
>
> > > Vik
> > > Founderwww.sakshum.comwww.sakshum.blogspot.com
>
> > --
> > 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]<google-web-toolkit%[email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/google-web-toolkit?hl=en.

-- 
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