Thursday, November 25, 2010

addClickHandler

when i use this code everything works fine.

SUCCESS====================================
public class PickupLocation extends Composite{

private static PickupLocationUiBinder uiBinder = GWT
.create(PickupLocationUiBinder.class);

interface PickupLocationUiBinder extends UiBinder<Widget,
PickupLocation> {
}

@UiField
TextBox streetNumber;
TextBox streetName;
//Button locateButton;

public PickupLocation() {
initWidget(uiBinder.createAndBindUi(this));

final Button locateButton = new Button("Add");

// Listen for mouse events on the Add button.
locateButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
locatePoint();
}
});
}

private void locatePoint() {
// TODO Auto-generated method stub
}

}


but when i change the code to use my "button" from uiBinder xml file
it gives me a null pointer error.

FAILS===========================
public class PickupLocation extends Composite{

private static PickupLocationUiBinder uiBinder = GWT
.create(PickupLocationUiBinder.class);

interface PickupLocationUiBinder extends UiBinder<Widget,
PickupLocation> {
}

@UiField
TextBox streetNumber;
TextBox streetName;
Button locateButton;

public PickupLocation() {
initWidget(uiBinder.createAndBindUi(this));

// Listen for mouse events on the Add button.
locateButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
locatePoint();
}
});
}

private void locatePoint() {
// TODO Auto-generated method stub
}

}

=============================
here the code from my ui.xml file
<g:customCell><g:Button ui:field="locateButton">Locate </g:Button></
g:customCell>

any help would be appreciated.

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

No comments:

Post a Comment