I need to make a simple refresh button for a gui java program I have the button made but its not working properly. I just am not sure what the code needs to be to make the button work. Any help would be really appreciated.I figured the code below
`
refeshButton.addListener(new ButtonListenerAdapter() {
@Override
public void onClick(Button button, EventObject e) {
// Window.alert("text" + button.getText());
if (button.getText().equals("Refresh")) {
sendDataToServ1("Refresh");
}
}
public void sendDataToServ1(String action) {
System.out.println("ACTION :----->" + action);
AsyncCallback<com.viji.example.domain.Record> callback = new AsyncCallback<com.viji.example.domain.Record>() {
@Override
public void onFailure(Throwable caught) {
System.out.println("Failure");
}
public void onSuccess(com.viji.example.domain.Record result) {
CompanySampledetails(result, 1);
}
};
if (action.trim().equals("Refresh")) {
System.out.println("Before Refresh");
dbService.getRecords(callback);
}
}
});
Warning: The local variable
buttonClickListeneris never read.After you create it, try saying
refeshButton.addListener(buttonClickListener);Edit:
The method
sendDataToServ(String action)never references its parameter. This is the method called by your listener. Did you mean to callsendDataToServer(String action)instead? If that’s the case, it does practically nothing with its parameter either. All it does it testsactionagainst the string “Add”.You should try tossing around a liberal amount of logging statements.