This week's book giveaway is in the Design and Architecture forum.
We're giving away four copies of Communication Patterns: A Guide for Developers and Architects and have Jacqui Read on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

How insert image to primefaces commandbutton?

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have some problem to insert an image to a <p:commandButton>.

Someone can show me a complete example?

My situation is:

IDE: NetBeans 7.1
Primefaces v. 2.2.1
<project>
/web Pages/resources/css/images.css
/Web pages/resources/images/Save.png

The file images.css contains only:

.save{
background-image: url("images/Save.png") !important;
}


in the JSF page:

....
<h:head>
<title>Inserimento Persona</title>
<h:outputStylesheet name="css/jsfcrud.css"/>
<h:outputStylesheet name="css/images.css"/>
</h:head>
....
<p:toolbar>
<p:toolbarGroup align="left">
<p:commandButton type="button" image="save"/>
</p:toolbarGroup>
</p:toolbar>

Where is the error(s)?

Thank you.

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello, I run into the same problem and didn't find a lot workaround.

Anyway, I suggest to look through this link Changing the image of a h:commandButton using CSS

In brief, for your case:
CSS


XHTML


First 2 buttons are Primefaces, the last one is not.

In output first button will be strange, with "^" symbol on it. (It is bad)
Last two will be normal, with specified image on it. The problem for primefaces button is that image will be replaced with white background when mouse is over.
At the moment I'm looking for solution to this problem. Any suggestions will be welcome)

And sorry for my English, please.
 
I AM MIGHTY! Especially when I hold this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic