Where are located JSF libraries on JBoss AS 6 ?

 

They are placed in your <server>\deployers\jsf.deployer. There you will
find several JSF implementation- basically you can opt between Mojarra-1.2 (JSF 1.2) and Mojarra-2.0 (JSF 2.0). By default JBoss 6 uses Mojarra-2.0.

Here's a sample HelloWorld application which can be used to test your JSF 2.0 environment.
Add a sample.xhtml page to your Web content.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
 xmlns:h="http://java.sun.com/jsf/html"
 xmlns:f="http://java.sun.com/jsf/core">

<h:body>
 <h:form>
 <f:view>

 <h:form id="helloForm">
 <h:outputText value="#{person.prompt}" />

 <h:inputText id="name" value="#{person.personName}" />
 <h:commandButton value="go" action="#{person.doSomething}" />

 </h:form>
 </f:view>
 </h:form>
</h:body>
</html>

An this is the corresponding Managed Bean (notice we declare it using a simple @ManagedBean annotation). The expected result is to uppercase the text contained in the field personName.
package sample;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;

@ManagedBean(name="person")
@RequestScoped

public class PersonBean {

 String personName;
 String prompt;

 public PersonBean() {
 this.prompt="Enter your name please";
 }

 public String getPrompt() {
 return prompt;
 }

 public void setPrompt(String prompt) {
 this.prompt = prompt;
 }

 public String getPersonName() {
 return personName;
 }

 public void setPersonName(String name) {
 personName = name;
 }
 public void doSomething() {
 personName= personName.toUpperCase();
 }

}

And now some specific questions about JSF and JBoss.

Question: How can I use JSF 1.2 with JBoss 6 ?

You can at any time switch to JSF 1.2 implementation by adding in your web.xml file

<context-param>
 <param-name>org.jboss.jbossfaces.JSF_CONFIG_NAME</param-name>
 <param-value>Mojarra-1.2</param-value>
 </context-param>

Question: do I need to specify anything related to JSF in my web.xml ?
It's not required anymore in JBoss 6. Since JBoss 6 a Web application is JSF 2.0 compliant if you have either:

  • A faces-config.xml file is found in WEB-INF
  • A faces-config.xml file is found in META-INF of some jar in WEB-INF/lib


Or if you set to true the following property into <server>\deployers\jsf.deployer\META-INF\jsf-integration-deployer-jboss-beans.xml

<property name="alwaysAddJSF">true</property>

Question: Should I deploy my Web application with JSF libs ?
No, you shouldn't. However there are some scenarios where you might want to bundle JSF libs with your WAR.  For instance, you might have an old JSF application that uses MyFaces and you don't want to retest your app on a new JSF implementation.  In that case, you can bundle the JSF implementation with your WAR and add this to your web.xml:
<context-param>
 <param-name>org.jboss.jbossfaces.WAR_BUNDLES_JSF_IMPL</param-name>
 <param-value>true</param-value>
</context-param> 

This will cause JBoss to ignore the built-in JSF implementation as long as you use the default classloader settings

 

References: http://docs.jboss.org/jbossas/6/JSF_Guide/en-US/html/index.html

0
0
0
s2smodern