以编程方式访问JSF和Primefaces版本号 [英] Access JSF and Primefaces version numbers programmatically
本文介绍了以编程方式访问JSF和Primefaces版本号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用PrimeFaces 3.5.x和Mojarra JSF 2.1.x 我想以编程方式访问和显示两个库的版本.
I use PrimeFaces 3.5.x and Mojarra JSF 2.1.x I would like to access and show the versions of both libraries programmatically.
我将版本用作maven2属性,但我希望有一种更简单的方法来获取版本. 我希望找到类似的东西:
I use the versions as maven2 properties, but I hope there is an easier way to get the versions. I hope to find something like:
Primeface.getVersion();
FacesContext.getCurrentInstance();
基于JavaScript的解决方案也可以,因为我只想在状态页面上显示版本.
A JavaScript based solution would be fine too, since I only want to display the version on a status page.
推荐答案
对于 JSF :
//returns the major version (2.1)
FacesContext.class.getPackage().getImplementationVersion();
//returns the specification version (2.1)
Package.getPackage("com.sun.faces").getSpecificationVersion();
//returns the minor implementation version (2.1.x)
Package.getPackage("com.sun.faces").getImplementationVersion();
For Primefaces 3.x you can use the Constants
class in utils package:
import org.primefaces.util.Constants;
Constants.VERSION
这篇关于以编程方式访问JSF和Primefaces版本号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文