Question

I have following handler

textArea.addKeyDownHandler(new KeyDownHandler() {
            @Override
            public void onKeyDown(KeyDownEvent event) {
                //here
            }
        });

I need to enable save button with id "idsave", but I am not able to refer the button. I am new to GWT, any help would be appreciated.

Was it helpful?

Solution 2

If you don't have the reference of the button then try with the id.

// get element by id
Element saveButtonElement = RootPanel.get("idsave").getElement(); 

// remove disabled attribute to make it enable
saveButtonElement.removeAttribute("disabled"); 

OTHER TIPS

Typically, you do not use element ids in GWT. If you created a button, you can simply use it:

private Button saveButton;
...

saveButton = new Button("Save");
textArea.addKeyDownHandler(new KeyDownHandler() {
     @Override
     public void onKeyDown(KeyDownEvent event) {
          saveButton.setEnabled(true);
     }
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top