Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

show icon with p:commandLink

How to show an icon with commandLink:

<p:commandLink 
         styleClass="ui-icon ui-icon-plus"
         action="#{bean.doSomething}"     >

         <h:outputText value="Add" />   
</p:commandLink>

The outputText (Add) is not visible. What is the right way for commandLink to support icon? Thanks.

like image 368
Dave Avatar asked Oct 15 '16 04:10

Dave


2 Answers

<p:commandLink action="#{bean.doSomething}">
     <h:outputText value="Add" class="ui-icon ui-icon-plus"/>   </p:commandLink>
like image 64
wysouf Avatar answered Sep 19 '22 23:09

wysouf


My answer is a bit of a combination of the previous two answers, but it worked the best for me. Remove styleClass, but you don't need to use graphicImage.

Instead you can use the <i class=""></i> tag.

    <p:commandLink action="#{bean.doSomething}">
        <h:outputText value="Add"/><i class="ui-icon ui-icon-plus"></i>
    </p:commandLink>
like image 39
T.Kruger Avatar answered Sep 20 '22 23:09

T.Kruger