Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Image as a commandButton  RSS feed

 
t kk
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All
How ca I use image i h:commandButton?
Is this the right approach <h:commandButton image="path" action="#{}"/>
I am trying to do something like above but method in bean doesnt get called

Any advise?
 
Varun Khanna
Ranch Hand
Posts: 1400
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Explore <h:graphicImage> tag.
 
Jussi Taimiaho
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My solution for similary prob was:



<h:commandLink id="removeFromOmatTyot" action="#{tyolistaBean.removeFromOmatTyot}" value="">
<x iv styleClass="#{tyolistaBean.buttonFromOmatTyotClass}"><f:verbatim> </f:verbatim></x iv>
</h:commandLink>

And the styleClass in css is:

.nappi-alas-disabled {
background-image: url('/kv/images/nappi-alas-disabled.jpg');
width: 34px;
height: 21px;
}
 
Sergey Smirnov
Ranch Hand
Posts: 167
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Replace
image="path"
with
image="#{facesContext.externalContext.requestContextPath}/path"

Where "path" is a context relative path to the image.

--
Sergey : jsfTutorials.net
 
Rick Beaver
Ranch Hand
Posts: 464
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi t kk

You might get in trouble with that display name - you can change it in your profile I think. The gunslingers like real names on the forum.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!