webtier@glassfish.java.net

Re: [webtier] JSF 2.0 in Glassfish..

From: Felipe Gaścho <fgaucho_at_gmail.com>
Date: Fri, 16 Oct 2009 19:29:16 +0200

The last failed attempt: http://fgaucho.dyndns.org:8080/arena-jsf20



----------- The XHTML code:
<!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">
<h:head>
        <title>JSF 2.0: Server Test</title>
        <link href="./css/styles.css" rel="stylesheet" type="text/css" />
</h:head>
<h:body>
        <div align="center">
        <h2>Finally: #{hellbean.customerId}</h2>
        <h2>No customer found with id "#{bankingBean.customerId}"</h2>
        </div>
</h:body>
</html>

---------- The Managed Bean:

@ManagedBean(name = "hellbean", eager = true)
public class TestBean {
        public String getCustomerId() {
                return "Arena-PUJ-jsf20";
        }
}

---------- web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
      http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
        version="2.5">
        <servlet>
                <servlet-name>Faces Servlet</servlet-name>
                <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        </servlet>
        <servlet-mapping>
                <servlet-name>Faces Servlet</servlet-name>
                <url-pattern>*.jsf</url-pattern>
        </servlet-mapping>
        <context-param>
                <param-name>javax.faces.PROJECT_STAGE</param-name>
                <param-value>Development</param-value>
        </context-param>
        <welcome-file-list>
                <welcome-file>index.jsp</welcome-file>
                <welcome-file>index.html</welcome-file>
        </welcome-file-list>
</web-app>


----------- faces-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<faces-config xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-facesconfig_2_0.xsd"
    version="2.0">
  <navigation-rule>
    <from-view-id>/health-plan-signup-2.xhtml</from-view-id>
    <navigation-case>
      <from-outcome>accepted</from-outcome>
      <to-view-id>/page-for-accepted.jsp</to-view-id>
    </navigation-case>
    <navigation-case>
      <from-outcome>rejected</from-outcome>
      <to-view-id>/page-for-rejected.jsp</to-view-id>
    </navigation-case>
  </navigation-rule>
</faces-config>