Marouane Gazanayi
Marouane Gazanayi

Reputation: 5183

How to change the url of a g:image in gwt

I'm new to GWT. I created in my ui.xml a panel containing an Image. I want to change the url, the alt & the title of that image depending some conditions. How to do it ?

<g:Image url="images/document-statut-1.gif" title="My title" altText="My alt"></g:Image>

Thnx

Upvotes: 1

Views: 4660

Answers (1)

Colin Alworth
Colin Alworth

Reputation: 18331

Modify the uibinder element so it has a field name:

<g:Image url="images/document-statut-1.gif" ui:field="imageWidget"
         title="My title" altText="My alt" />

Then make a matching field in your java code:

@UiField
Image imageWidget;

Any time after you call the createAndBind method in your java class, you can then assign a new url:

imageWidget.setUrl("images/newStatus.gif");

Upvotes: 9

Related Questions