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

萝らか妹 提交于 2019-12-24 15:00:00

问题


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


回答1:


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


来源:https://stackoverflow.com/questions/9720758/how-to-change-the-url-of-a-gimage-in-gwt

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!