tags:

views:

108

answers:

1

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

                }

            }
        });
+2  A: 

Warning: The local variable buttonClickListener is 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 call sendDataToServer(String action) instead? If that's the case, it does practically nothing with its parameter either. All it does it tests action against the string "Add".

You should try tossing around a liberal amount of logging statements.

Gunslinger47
I tried it also.... But its not working.refeshButton.addListener(new ButtonListenerAdapter() { @Override public void onClick(Button button, EventObject e) { // Window.alert("text" + button.getText()); if (button.getText().equals("Refresh")) { sendDataToServ("Refresh"); } } });
lakshmi