Questo contenuto non è disponibile nella lingua selezionata.
Chapter 19. Jakarta Server Faces configuration
The jsf subsystem enables the installation of multiple Jakarta Server Faces implementations on the same JBoss EAP server instance. You can install a version of Sun Mojarra or Apache MyFaces that implements the Jakarta Server Faces 4.0 specification or later. The feature pack can only be used to install the Apache MyFaces implementation.
Only the Jakarta Server Faces implementation included with JBoss EAP is fully supported.
19.1. Installing a Jakarta Server Faces implementation Copia collegamentoCollegamento copiato negli appunti!
JBoss EAP supports provisioning a server with only the necessary features by using the JBoss EAP Installation Manager, which delivers these features as feature packs.
Prerequisites
- You have installed JBoss EAP.
Procedure
Create the
myfaces-manifest.yamlfile with the following content:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the MyFaces manifest by using the following command:
$JBOSS_HOME/bin/jboss-eap-installation-manager.sh channel add \ --channel-name=myfaces \ --manifest=myfaces-manifest.yaml \ --repositories=https://repo1.maven.org/maven2/
$JBOSS_HOME/bin/jboss-eap-installation-manager.sh channel add \ --channel-name=myfaces \ --manifest=myfaces-manifest.yaml \ --repositories=https://repo1.maven.org/maven2/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Deploy the MyFaces Maven manifest to your local Maven repository by using the following command:
mvn deploy:deploy-file -Dfile=myfaces-manifest.yaml \ -DgroupId=org.apache.myfaces.channel -DartifactId=myfaces \ -Dclassifier=manifest -Dpackaging=yaml -Dversion=4.0.2 \ -Durl=file://$HOME/.m2/repository
mvn deploy:deploy-file -Dfile=myfaces-manifest.yaml \ -DgroupId=org.apache.myfaces.channel -DartifactId=myfaces \ -Dclassifier=manifest -Dpackaging=yaml -Dversion=4.0.2 \ -Durl=file://$HOME/.m2/repositoryCopy to Clipboard Copied! Toggle word wrap Toggle overflow Provision a server using the MyFaces feature pack by using the following command:
$JBOSS_HOME/bin/jboss-eap-installation-manager.sh fp add \ --fpl=org.jboss.eap:eap-myfaces-feature-pack \ --layers=myfaces
$JBOSS_HOME/bin/jboss-eap-installation-manager.sh fp add \ --fpl=org.jboss.eap:eap-myfaces-feature-pack \ --layers=myfacesCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Start the server.
Verification
Use the following CLI command to verify that the new Jakarta Server Faces implementation has been installed successfully:
[standalone@localhost:9990 /] /subsystem=jsf:list-active-jsf-impls()
[standalone@localhost:9990 /] /subsystem=jsf:list-active-jsf-impls()Copy to Clipboard Copied! Toggle word wrap Toggle overflow
19.2. Changing the default Jakarta Server Faces implementation Copia collegamentoCollegamento copiato negli appunti!
The multi-Jakarta Server Faces feature includes the default-jsf-impl-slot attribute in the jsf subsystem, which enables you to change the default Jakarta Server Faces implementation.
Prerequisites
- You have the multiple Jakarta Server Faces implementations installed on the server.
Procedure
Use the
write-attributecommand to set the value of thedefault-jsf-impl-slotattribute to one of the active Jakarta Server Faces implementations:/subsystem=jsf:write-attribute(name=default-jsf-impl-slot,value=JSF_IMPLEMENTATION)
/subsystem=jsf:write-attribute(name=default-jsf-impl-slot,value=JSF_IMPLEMENTATION)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace
JSF_IMPLEMENTATIONwith the name of the Jakarta Server Faces implementation you want to set as default.Restart the JBoss EAP server for the change to take effect.
reload
reloadCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Identify the available Jakarta Server Faces implementations by using the following command:
/subsystem=jsf:read-attribute(name=default-jsf-impl-slot)
/subsystem=jsf:read-attribute(name=default-jsf-impl-slot)Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Expected output
{ "outcome" => "success", "result" => "myfaces" }{ "outcome" => "success", "result" => "myfaces" }Copy to Clipboard Copied! Toggle word wrap Toggle overflow
19.3. Jakarta Server Faces application configuration for non-default implementation Copia collegamentoCollegamento copiato negli appunti!
To configure a Jakarta Server Faces application to use a Jakarta Server Faces implementation other than the default, add the org.jboss.jbossfaces.JSF_CONFIG_NAME context parameter to the web.xml file. This parameter instructs the jsf subsystem to apply the specified Jakarta Server Faces implementation when deploying the application.
For example, if you want to use MyFaces 4.0.0 in your application, include the following context parameter in the web.xml file:
<context-param>
<param-name>org.jboss.jbossfaces.JSF_CONFIG_NAME</param-name>
<param-value>myfaces-4.0.0</param-value>
</context-param>
<context-param>
<param-name>org.jboss.jbossfaces.JSF_CONFIG_NAME</param-name>
<param-value>myfaces-4.0.0</param-value>
</context-param>
If a Jakarta Server Faces application does not include this context parameter, the 'jsf' subsystem will use the default Jakarta Server Faces implementation.
19.4. Disallowing DOCTYPE declarations Copia collegamentoCollegamento copiato negli appunti!
You can configure the jsf subsystem to disallow DOCTYPE declarations in Jakarta Server Faces deployments. This setting improves security by preventing the use of external entities.
Prerequisites
-
You have management CLI access to configure the
jsfsubsystem.
Procedure
Disallow
DOCTYPEdeclarations in all Jakarta Server Faces deployments by using the following command:/subsystem=jsf:write-attribute(name=disallow-doctype-decl, value=true)
/subsystem=jsf:write-attribute(name=disallow-doctype-decl, value=true)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Restart the JBoss EAP server for the changes to take effect:
reload
reloadCopy to Clipboard Copied! Toggle word wrap Toggle overflow To allow
DOCTYPEdeclarations for a specific Jakarta Server Faces deployment, add thecom.sun.faces.disallowDoctypeDeclcontext parameter to the deployment’s web.xml file with the following configuration:<context-param> <param-name>com.sun.faces.disallowDoctypeDecl</param-name> <param-value>false</param-value> </context-param><context-param> <param-name>com.sun.faces.disallowDoctypeDecl</param-name> <param-value>false</param-value> </context-param>Copy to Clipboard Copied! Toggle word wrap Toggle overflow