0

Hi I have an image that that has arrows. I want to add "alt" attribute.

here is my class:

public interface DisclosurePanelArrows extends ClientBundle
{

    public static final DisclosurePanelArrows INSTANCE = GWT.create(DisclosurePanelArrows.class);

    @Source("disclosurePanelClosed.png")
    ImageResource disclosurePanelClosed();


    @Source("disclosurePanelOpen.png")
    ImageResource disclosurePanelOpen();

}

I used it in here: (not working)

 closedImage = new ICMImage(DisclosurePanelArrows.INSTANCE.disclosurePanelClosed());
        openImage = new ICMImage(DisclosurePanelArrows.INSTANCE.disclosurePanelOpen());
 closedImage.getElement().setAttribute("alt", "close test alt");
        openImage.getElement().setAttribute("alt", "open test alt");

I noticed that the HTML tags are being created programatically and produces it in a .gwtml file.

The only js i found linked to it is this which is in the WAR folder so I am not sure.

function com_irondata_icmcase_ICMCase(){var O='',vb='" for "gwt:onLoadErrorFn"',tb='" for "gwt:onPropertyErrorFn"',hb='"><\/script>',Y='#',cc='../css/ICMCase.css',dc='../css/dummy.css',bc='../css/theme.css',Wb='.cache.html',$='/',Rb='3A2B8EBB69B48C7A8A7573A74E0C6812',Sb='59203CCA1EBBD79FD6BB80354E15F64D',Vb=':',nb='::',kc='<script defer="defer">com_irondata_icmcase_ICMCase.onInjectionDone(\'com.irondata.icmcase.ICMCase\')<\/script>',gb='<script id="',gc='<script language="javascript" src="',qb='=',Z='?',Eb='ActiveXObject',sb='Bad handler "',Tb='C3CB1347D72F2C0FB0DF18AB080081C2',Fb='ChromeTab.ChromeFrame',Ub='DDDD212960179CCBED9A98B8863C29E1',ec='DOMContentLoaded',ib='SCRIPT',fb='__gwt_marker_com.irondata.icmcase.ICMCase',jb='base',bb='baseUrl',S='begin',R='bootstrap',Db='chromeframe',ab='clear.cache.gif',P='com.irondata.icmcase.ICMCase',db='com.irondata.icmcase.ICMCase.nocache.js',mb='com.irondata.icmcase.ICMCase::',pb='content',X='end',Lb='gecko',Mb='gecko1_8',T='gwt.codesvr=',U='gwt.hosted=',V='gwt.hybrid',Xb='gwt/chrome/chrome.css',ub='gwt:onLoadErrorFn',rb='gwt:onPropertyErrorFn',ob='gwt:property',ac='head',Pb='hosted.html?com_irondata_icmcase_ICMCase',_b='href',Kb='ie6',Jb='ie8',Ib='ie9',wb='iframe',_='img',xb="javascript:''",fc='js/amathcontext.js',hc='js/amathcontext.js"><\/script>',ic='js/bigdecimal.js',jc='js/bigdecimal.js"><\/script>',Yb='link',Ob='loadExternalRefs',kb='meta',zb='moduleRequested',W='moduleStartup',Hb='msie',lb='name',Bb='opera',yb='position:absolute;width:0;height:0;border:none;alt=""',Zb='rel',Gb='safari',cb='script',Qb='selectingPermutation',Q='startup',$b='stylesheet',eb='undefined',Nb='unknown',Ab='user.agent',Cb='webkit';var l=window,m=document,n=l.__gwtStatsEvent?function(a){return l.__gwtStatsEvent(a)}:null,o=l.__gwtStatsSessionId?l.__gwtStatsSessionId:null,p,q,r,s=O,t={},u=[],v=[],w=[],x=0,y,z;n&&n({moduleName:P,sessionId:o,subSystem:Q,evtGroup:R,millis:(new Date).getTime(),type:S});if(!l.__gwt_stylesLoaded){l.__gwt_stylesLoaded={}}if(!l.__gwt_scriptsLoaded){l.__gwt_scriptsLoaded={}}function A(){var b=false;try{var c=l.location.search;return (c.indexOf(T)!=-1||(c.indexOf(U)!=-1||l.external&&l.external.gwtOnLoad))&&c.indexOf(V)==-1}catch(a){}A=function(){return b};return b}

I also tried this solution but it is putting the alt in diff tag

Any suggestions? thanks.

4

2 回答 2

1

假设ICMImage是一种com.google.gwt.user.client.ui.Image,那又如何setAltText呢?

否则,请显示 的代码ICMImage,因为您没有显示如何使用ImageResource.

于 2012-06-01T10:17:20.487 回答
0

我找到了。经过8个多小时的努力。这是答案。

 protected DisclosurePanel         disclosurePanel;

  if(disclosurePanel.getElement().hasChildNodes()) 
        { 
            NodeList<com.google.gwt.dom.client.Element> imgs =  disclosurePanel.getElement().getElementsByTagName("img");
            com.google.gwt.dom.client.Element elem = imgs.getItem(0);
            elem.setAttribute("alt", " ");
        }
于 2012-06-01T07:06:22.883 回答