what dictates JSF version? Container or faces-conf

2019-01-25 14:07发布

I am currently running a legacy JSF application on JBoss AS 4.3. I believe that this implements JSF 1.2. However, when I looked at the faces-config, I saw that it was using the JSF 1.1 DTD.

Which version of JSF am I using?

1条回答
走好不送
2楼-- · 2019-01-25 15:06

The exact JSF implementation version information is available in /META-INF/MANIFEST.MF file of the JSF implementation JAR file. It's usually located near the bottom of the manifest file as follows:

Implementation-Title: Mojarra
Implementation-Version: 1.2_12-b01-FCS
Implementation-Vendor: Sun Microsystems, Inc.

A JAR file can be opened with a ZIP tool. In case of Sun RI / Mojarra, the filename is jsf-impl.jar, sometimes already suffixed with exact version number such as jsf-impl-1.2_12-b01-FCS.jar. If you're using the JSF implementation supplied by JBoss 4.3.x, then you can find the file in $JBOSS_HOME/server/<Profile>/deploy/jboss-web.deployer/jsf-libs folder. If you supplied your own JSF implementation in /WEB-INF/lib and configured web.xml to tell JBoss to use it instead, then you need to check it in the one supplied in /WEB-INF/lib instead.

Or, you can just get it programmatically:

Package jsfPackage = FacesContext.class.getPackage();
String implTitle = jsfPackage.getImplementationTitle();
String implVersion = jsfPackage.getImplementationVersion();
String implVendor = jsfPackage.getImplementationVendor();

As to the faces-config.xml, with it you can also control what JSF version the application is designed for. So if you declared it conform JSF 1.1 spec, then even a JSF 1.2/2.0 implementation will run in JSF 1.1 "compatibility modus". But you cannot declare it conform a newer version like JSF 1.2/2.0 when you're actually using a JSF 1.1 implementation. It will either error out or be ignored.

查看更多
登录 后发表回答