2013-05-17 58 views
1

我一直在努力这一段时间。我正在使用primefaces 3.5。我有一个带有图标属性的命令按钮。但图像似乎没有显示。我不确定我是否正确地放置了图片网址。我试了几条路。但仍然没有工作。在萤火虫中,我可以看到图标。<p:commandButton>不显示图标图像

我的形象居住在/ BelsizeWeb /的WebContent /主题/ primefaces-ARISTO /图像 CSS驻留在/ BelsizeWeb /的WebContent /主题/ primefaces-ARISTO

theme.css

.ui-icon-excel { 
    background-image: url("images/toexcel.gif"); 
} 

XHTML

<link type="text/css" rel="stylesheet" 
    href="#{request.contextPath}/theme/primefaces-aristo/theme.css" /> 

<p:commandButton type="submit" 
       styleClass="commandExButton_image" id="cr1001_command_toexcel" 
       icon="ui-icon-excel" 
       action="#{pc_Cr1001.doCr1001_command_toexcelAction}" ajax="false"> 
       </p:commandButton> 

回答

1

Icon属性将工作PrimeFaces(jQuery用户界面)只有preifinded图标。

要解决您的需求有两种方法。 P的

使用图片:的commandButton

修改你的CSS类,如下图所示,

 .ui-icon-excel { 
      background: url("images/toexcel.gif") no-repeat top left !important;; 
    } 

然后用你的命令按钮,如下图所示,

<p:commandButton type="submit" 
      id="cr1001_command_toexcel" 
      image="ui-icon-excel" 
      action="#{pc_Cr1001.doCr1001_command_toexcelAction}" ajax="false"> 
      </p:commandButton> 

2.使用jsf h:commandButton如下所示,

<h:commandButton image="images/toexcel.gif"/> 

可以ajaxify H:进一步的commandButton

+0

感谢您的答复。我可以知道!重要的手段是什么?我对此感到困惑。 – hahagal

+0

在这里结帐http://www.w3.org/TR/CSS21/cascade.html#important-rules – Jitesh