Access JSF and Primefaces version numbers programmatically

后端 未结 4 459
不知归路
不知归路 2021-01-03 00:52

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.

I use the versions as maven2 properties

4条回答
  •  春和景丽
    2021-01-03 01:32

    For 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
    

提交回复
热议问题