gwtbootstrap3

Reference elements in GwtBootstrap3 in code


I'm very new to GWT and GwtBootstrap3 so this might be a dumb question, but how can the elements from my ***.ui.xml file be referenced in the code?

For example, I have a paragraph in my ***.ui.xml file -

    <b.html:Paragraph alignment="LEFT">
        Lorem Ipsum
    </b.html:Paragraph>     

and I want to be able to change the text in my code. Similarly, if I'm creating a List but can't statically provide the list elements in my ***.ui.xml file and need to provide them in my code, based on what choices are available, is there a way to do that?

Any suggestions/comments will be really appreciated.


Solution

  • Rohit, I noticed in your answer you changed your initial paragraph widget to a Label element. For anyone else visiting this question and wanting to work specifically with paragraphs: adding the attribute ui:field="myWidget" to an html Paragraph Element will allow you to perform this task directly

    UIBinder

    xmlns:b.html="urn:import:org.gwtbootstrap3.client.ui.html"    
    
    <b.html:Paragraph alignment="LEFT" ui:field="myWidget">
        Lorem Ipsum
    </b.html:Paragraph>
    

    Java

    import org.gwtbootstrap3.client.ui.html.Paragraph;
    
    @UiField public Paragraph myWidget;
    
    myWidget.setText("Dynamic text");