3 Replies Latest reply on May 22, 2009 12:41 AM by gonorrhea

    JSP not accessing my Beans

    yasudevil
      Hi I'm really new on the Seam and JSF scenario and it's beeing a preety though but refreshing experience so far.

      At the moment i'm trying to make a simple Hello World like application without EJB or JPA.

      My configuration files are the following:

      faces-config.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee"
      xmlns:xi="http://www.w3.org/2001/XInclude"
      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_1_2.xsd">
      <!--  adicionado par ao seam -->
      <lifecycle>
        <phase-listener>org.jboss.seam.jsf.SeamPhaseListener</phase-listener>
      </lifecycle>
      </faces-config>


      sun-web.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Application Server 9.0 Servlet 2.5//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_2_5-0.dtd">
      <sun-web-app error-url="">
        <context-root>/testeSeam</context-root>
        <class-loader delegate="true"/>
        <jsp-config>
          <property name="classdebuginfo" value="true">
            <description>Enable debug info compilation in the generated servlet class</description>
          </property>
          <property name="mappedfile" value="true">
            <description>Maintain a one-to-one correspondence between static content and the generated servlet class' java code</description>
          </property>
        </jsp-config>
      </sun-web-app>

      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" id="WebApp_ID" version="2.5">
        <display-name>testeSeam</display-name>
        <welcome-file-list>
          <welcome-file>index.html</welcome-file>
          <welcome-file>index.htm</welcome-file>
          <welcome-file>index.jsp</welcome-file>
          <welcome-file>default.html</welcome-file>
          <welcome-file>default.htm</welcome-file>
          <welcome-file>default.jsp</welcome-file>
        </welcome-file-list>
       
        <context-param>
              <param-name>com.sun.faces.verifyObjects</param-name>
              <param-value>false</param-value>
          </context-param>
          <context-param>
              <param-name>com.sun.faces.validateXml</param-name>
              <param-value>true</param-value>
          </context-param>
         
        <!--  adicionado para o seam ?? -->
        <context-param>
              <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
              <param-value>client</param-value>
        </context-param>
       
        <!-- adicionado para o seam -->
        <!--
        <context-param>
           <param-name>
                 org.jboss.seam.core.init.jndiPattern
           </param-name>
           <param-value>
                 java:comp/env/your ear name/#{ejbName}/local
           </param-value>   
        </context-param> -->
       
        <!-- adicionado para o seam -->
        <listener>
              <listener-class>
              org.jboss.seam.servlet.SeamListener
              </listener-class>
        </listener>
       
        <filter>
          <filter-name>Seam Filter</filter-name>
          <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
        </filter>
        <filter-mapping>
          <filter-name>Seam Filter</filter-name>
          <url-pattern>/*</url-pattern>
        </filter-mapping>
       
        <servlet>
          <servlet-name>Seam Resource Servlet</servlet-name>
          <servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class>
        </servlet>
       
       
        <servlet>
          <servlet-name>Faces Servlet</servlet-name>
          <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
          <load-on-startup>1</load-on-startup>
        </servlet>
       
        <servlet-mapping>
          <servlet-name>Seam Resource Servlet</servlet-name>
          <url-pattern>/seam/resource/*</url-pattern>
        </servlet-mapping>
       
        <servlet-mapping>
          <servlet-name>Faces Servlet</servlet-name>
          <url-pattern>*.seam</url-pattern>
        </servlet-mapping>
      </web-app>

      index.jsp
      <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
          pageEncoding="ISO-8859-1"%>
      <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>

      <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
      <html>
      <head>
      <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
      <title>Test Seam</title>
      </head>
      <body>
      <f:view>
              <h:outputText value="#{user.name}" />
      </f:view>
      </body>
      </html>`

      `package bean;

      import javax.persistence.Entity;

      import org.jboss.seam.annotations.Name;

      @Entity
      @Name("user")
      public class User{
             
              protected String name= "hello";
             
              public String getNome() {
                      return name;
              }
             
              public void setNome(String name) {
                      this.name = name;
              }
      }

      The application is deployed successufully but whe I acces the url for the page I get no error nor output.


        • 1. Re: JSP not accessing my Beans
          israel.bgf

          My advise to start your life with Seam would be: deploy the JPA Seam Example in the examples folder of the Seam. With that you can make your structure pretty well, and without the deprecated JSP. :)


          From the comments of your code, i can tell that you are Brazilian, or maybe Portuguese, me too, so if you want ideas just take my email.


          Good luck.

          • 2. Re: JSP not accessing my Beans
            yasudevil

            I would like to contact you by mail for sure :D. mine is a gmail user diegoy.


            I'll try to deploy one of the examples on glassfish then... thank you.

            • 3. Re: JSP not accessing my Beans
              gonorrhea

              Use facelets instead of JSP for the view technology of JSF.  facelets is now part of the spec for JSF 2.0.