2

I've been struggling trying to add an image to an IceFaces pushButton.

My last try was adding an image nested to pushbutton tags like this:

<ace:pushButton actionListener="#{logoutCtrl.logout()}">
        <h:graphicImage value="img/logout.png" width="20px" height="20px"/>
</ace:pushButton>

But unfortunately it didn't work. The page shows the button with no label and than the image, like:

Doesn't work!!!

I've found this link where they mentioned that it should be fixed since version 2.x, so I am probably doing something wrong.

P.S - I would normally use Prime Faces but I don't have a choice in this case.

groo
  • 4,213
  • 6
  • 45
  • 69

1 Answers1

1

I had a similar issue but with ICEFaces 4. In my case, the image would display next to the button. I guess, I could have styled the button in CSS. Instead I just replaced the ace:pushButton element with standard JSF h:commandButton component. The h:commandButton has an image attribute. Here is an example:

<h:commandButton image="#{resource['images:searchIcon.png']}" action="#{myBean.performSearch}"> <f:param name="callback" value="sessionSearch"/> </h:commandButton>

Hopefully this can help someone.

  • `` serves a different purpose in HTML (image map to get X,Y coordinates of mouse pointer). Just use ``. – BalusC Nov 05 '15 at 13:41
  • @BalusC, I was not aware of this. I guess since action is a redirect, your solution should be more elegant. I went with JSF documentation which states: [Absolute or relative URL of the image to be displayed for this button.(under image attribute h:commandButton component description)](https://docs.oracle.com/javaee/7/javaserver-faces-2-2/vdldocs-jsp/toc.htm) – Mike Kachaluba Nov 05 '15 at 13:55