只是一个基本的需求,但无法让它工作。 我想有一个primefaces按钮来显示我的图像,没有任何文字。需要帮助才能在命令按钮中显示图标图像
但我得到的是一个按钮,只包含一个^
字符,并不显示图像,它只有16x16的大小。
所以,这是primefaces按钮:
<p:commandButton image="ui-icon-csv" title="CSV Document" ajax="false">
<p:dataExporter type="csv" target="gridRPBDetails"
fileName="#{tInputBean.exportFilename}" />
</p:commandButton>
这是css文件:
.ui-icon-csv {
background-image: url(images/csv_small.png);
}
这是该按钮的生成html :
<button type="submit" onclick=";"
name="gridRPBDetails:j_idt82" id="gridRPBDetails:j_idt82"
class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-icon-primary"
role="button" aria-disabled="false">
<span class="ui-button-icon-primary ui-icon ui-icon-csv"></span><span class="ui-button-text">CSV Document</span>
</button>
为了证明图像访问,我试试这个URL,而事实上它显示的图片:使用Tomcat 7
http://albert:8080/mywebapp/faces/javax.faces.resource/images/csv_small.png
IM,而这些是我的依赖关系:
<dependency>
<groupId>org.primefaces</groupId>
<artifactId>primefaces</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-api</artifactId>
<version>2.0.4-b09</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
<version>2.0.4-b09</version>
<scope>compile</scope>
</dependency>
任何想法什么地方出了错 ?
谢谢!
你确定你的css找到了图像(正确的相对路径)吗?如果您请求包含该按钮的页面,请尝试使用Chrome/Firefox开发人员工具检查是否存在任何404错误。 – 2011-05-11 06:29:33
@Matt Handy:您好,非常感谢您的回复。是的,正如原文中所述,我可以使用该URL查看图像。而且我忘了提及,我设法查看图像也使用萤火虫。但是我已经找到了一些解决方案,然后在css周围进行了一些调整。如果您有兴趣,请参阅下面的答案。谢谢 ! – bertie 2011-05-12 10:25:39