3

In p:button in need add my own image(any image which i want to include).

`<p:button  icon="ui-icon-star" title="Icon Only">

</p:button>

`Can i add like this

 <p:button  icon=""/images/someimage.png"" title="Icon Only">

    </p:button>`
goku
  • 223
  • 2
  • 12

1 Answers1

3

The icon attribute of <p:button> needs a CSS class, you can not give it a image path. Example:

PrimeFaces button:

<p:button  icon="my-icon"  />

CSS:

.my-icon {
    background-image: url("images/myicon.png");
}
Mark
  • 16,772
  • 9
  • 42
  • 55
  • hi mark am not getting the image , i have included the css file in the header of my xhtml and include the .my-icon class in the css file but am not getting the image – goku Oct 30 '14 at 06:48
  • I am using primeface 3.3.1 , is it possible in that version – goku Oct 30 '14 at 06:56
  • Yes, this will work in PrimeFaces 3.3.1 as well. Make sure the path to your image in your CSS is correct. – Mark Oct 30 '14 at 14:51
  • thanks Mark , its worked but the image is coming along with button background i need only the image , is it possible ?? – goku Nov 03 '14 at 05:45
  • If you only want the image and not the button look at doing it this way .. http://stackoverflow.com/questions/9924603/how-to-make-pgraphicimage-clickable – Mark Nov 03 '14 at 13:25