2013-05-17 61 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