Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSF show icon without Button

Tags:

jsf

primefaces

I want to show the icons without buttons but it doesn't work. I get the following message: no Mime-Type was Found.

The two icons are default icons from Primefaces.

I use JSF 2.1 and primefaces 3.5

<h:graphicImage rendered="#{!task.IS_SEEN}" name="ui-icon-mail-closed"/>
<h:graphicImage rendered="#{task.IS_SEEN}" name="ui-icon-mail-closed"/>

If I use buttons it would work or can I set that the button can not be pressed

<p:commandButton rendered="#{!task.IS_SEEN}" icon="ui-icon-mail-closed" />
<p:commandButton rendered="#{task.IS_SEEN}" icon="ui-icon-mail-open" />
like image 624
bvb1909 Avatar asked Jan 10 '14 21:01

bvb1909


1 Answers

If you want just a clickable image that trigger an action in the backing bean I suggest wrapping a graphic image in a h:commandLink.

<h:commandLink rendered="#{!task.IS_SEEN}" value="" action="#{YourBean.myAction}">
    <h:graphicImage  value="your-image-here"/>
</h:commandLink>

If you want easy to use, nice, vectorial icons I suggest you to check Font Awesome http://fontawesome.io/icons/ as well.

To use Font Awesome just include the following line in your <h:head>:

<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet"></link>

Then you can easily put the icons inside commandLinks in this simple way:

<h:commandLink rendered="#{!task.IS_SEEN}" value="" action="#{YourBean.myAction}">
    <i class="fa fa-envelope"></i>
</h:commandLink>
like image 87
elbuild Avatar answered Sep 28 '22 22:09

elbuild