primefaces 2.2.M1 <p:commandButton image not work

UI Components for JSF
Post Reply
ertan
Posts: 7
Joined: 01 Oct 2010, 02:41

01 Oct 2010, 10:47

Hi,

<p:commandButton image="/resources/image/edit.png" type="image"/>
its not working and out put is

<button ....>
<span class="ui-button-icon-primary ui-icon /resources/image/edit.png"></span>
</button>

User avatar
michiel
Posts: 240
Joined: 07 Jun 2010, 09:12
Location: Belgium

01 Oct 2010, 11:27

the image-attribute is a css-class selector.
use it as:

Code: Select all

.image {
   background: url(/resources/image/edit.png) no-repeat top left;
}

<p:commandButton image="image" type="button"/>
JSF-2.0, mojarra-2.0.2-FCS and PrimeFaces-2.1 on GlassFish v3.0.1 (build 22)

ertan
Posts: 7
Joined: 01 Oct 2010, 02:41

01 Oct 2010, 13:36

Thanks form reply
but i think this solution has contain some diffuculty for developer. In a big project we must define css files for all pages and images.
.image_0 { }
...
.image_n { }

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

01 Oct 2010, 14:11

Every project usually has a main css for these so should not be an issue as it is reusable. This is much better than defining an image path for each button, what if the image changes? With css, it is centralized and controlled from one place.

Also you can create composite components like with JSF 2.0.

Code: Select all

<yourtag:saveButton />
That handles and label stuff.

ertan
Posts: 7
Joined: 01 Oct 2010, 02:41

02 Oct 2010, 21:27

Absolutely you are right about csses and images. But styleclass property defined. I am an user and I prefer to use some properties easily.

i18n
Posts: 33
Joined: 15 Aug 2010, 11:24

13 Oct 2010, 16:59

Hi

I'm code

Code: Select all

<style type="text/css">
 .image {
   background: url(/images/add.png) no-repeat top left;
}
...
<p:commandButton id="ekle" image="image" action="#{servisAdd.islemEkle}" title="İşlem ekle" update="bilesen11,islemListesi"/>
</style>
This code not work.

albatros
Posts: 27
Joined: 01 Apr 2011, 23:17

04 Apr 2011, 12:47

I have the same Problem.
I put the image attribute in my CSS file, the image doesn't show up!

The original settings are still active for the button:

Code: Select all

background: url("/beta/javax.faces.resource/themes/sam/images/ui-default.png.jsf?ln=primefaces") repeat-x scroll 0 0 #D8D8D8

albatros
Posts: 27
Joined: 01 Apr 2011, 23:17

05 Apr 2011, 13:30

Ok, it works but not as expected.
The image is embedded in a grey box, which is not resizeable.
My image is much more bigger. Is there a way to get just the image as a button without the box ?

Thanks

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 50 guests