Primefaces - set the style attribute dynamically

advertisements

I am using Primefaces graphicImage inside a p:tooltip and would like to set the width and height for the images individually.

 <p:remoteCommand....update="myImage" />

 <p:tooltip beforeShow="remoteCommand()">
   <p:graphicImage id="myImage"... style="#{myBean.myStyle}" />
....

Update: Bean.myStyle is triggered correctly and the style parameter is updated in the page source, but not in the dom tree. If I set style="width:100px" directly it works, but if the value comes from the bean, it is ignored.

It seems like the style-attribute of graphicImage gets updated but not the component itself.

What am I missing here?


I think style value is setted when the document is loaded and its never reloaded, when its visible just its display:none value is changing. So I would give an id to p:graphicImage then I would add a p:ajax using onShow or similar event (I dont know which one is available for tooltip) then I would use update attribute to render graphic image. If I remember right even it should work just with <p:ajax /> without any attribute but I am not sure

So it should look like that:

<p:graphicImage id="x" style="#{bean.value}">
  <p:ajax event="show" update"x"/>
</p:graphicImage>