简体   繁体   中英

JSF commandLink with image

I have problem with <p:commandLink> . I want make hover effect but I can't load image to <p:graphicImage> via CSS.

CSS:

.accountEditBtn {
    background-image:
    url('#{request.contextPath}/resources/image/pencil_black.png');
}

JSF:

<p:commandLink
    update="@form"
    actionListener="#{someBean.someListener}">
    <h:graphicImage styleClass="accountEditBtn" />
</p:commandLink>

I see empty rectangle with border.

But when I add alt to graphicImage, I get image over text from alt...

Where my mistake? Thank you. ps typing error - classType -> styleClass

try using styleClass instead of <h:graphicImage>

<p:commandLink 
   styleClass="accountEditBtn"
   update="@form"
   actionListener="#{someBean.someListener}"/>

try this class

.accountEditBtn { background-image: url('../resources/image/pencil_black.png'); }

BTW

isn't is should be images ? or it is image (folder name)

take a look at this as well.. in case you want commandButton with image: PrimeFaces icons

Why don't you use

<p:commandButton ... icon="yourbuttonstyleclass"/>

and in css

.yourbuttonstyleclass {  
background-image: url('../images/yourimage.png') !important;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM