tags:

views:

31

answers:

2

i want to call click event function for Button in GWT... I tried this code but it is not working..

Button btnAddField = new Button();
btnAddField.setText("Add");
btnAddField.setWidth("225px");
btnAddField.addClickHandler(new btnAddFieldButtonClickListener());  


private class btnAddFieldButtonClickListener implements ClickHandler{   
        public void onClick(ClickEvent event) {
Window.alert("Called Click Event");
}
}

this function wiil call at click the button but it does not call when call this function btnAddField.click()

+1  A: 

If you like to fire the click event yourselfe, use

btnAddField.fireEvent(Event.CLICK)

instead of

btnAddField.click()
JochenJung
I tried this btnAddField.fireEvent(Event.CLICK)but fireEvent function does not supporting the integer value...it shows error
Kandhasamy
+1  A: 

I solve that problem by using this code

btnAddField.fireEvent(new ButtonClickEvent ())

private class ButtonClickEvent extends ClickEvent{
        /*To call click() function for Programmatic equivalent of the user clicking the button.*/
    }

It is working fine now.

Kandhasamy