Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GWT uibinder composite

I'm creating a composite uibinder widget with a Label and a TextBox.

The intented use is:

<x:XTextBox ui:field="fieldName" label="a caption" >
    The text to be put in the box.
</x:XTextBox>

I've found how to catch the label with a custom @UiConstructor constructor, I might add another parameter to the constructor, but I would like to know how to get the text from the xml, just like the GWT tag <g:Label>a caption</g:Label> does.

Any help is greatly appreciated.

like image 704
Han Fastolfe Avatar asked Feb 19 '26 15:02

Han Fastolfe


1 Answers

I've found a possible implementation by looking at the Label widget source code.

The key point is that the composite widget must implement the HasText interface. so in the declaration and in the body:

public class XTextBox extends Composite implements HasText ...
...
@UiField TextBox textBox;
...
public void setText(String text) {
    textBox.setText(text);
}
public String getText() {
    return textBox.getText();
}
...
like image 117
Han Fastolfe Avatar answered Feb 21 '26 13:02

Han Fastolfe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!