4 Replies Latest reply on Sep 17, 2008 9:17 PM by grabnj

    Annotation "@Name" not recognized

    grabnj

      Hello!


      I set up a working facelets project. The next step was to integrate
      Seam. I removed the MangedBean Tag from faces-config and added
      the @Name annotation to my bean and expected to have the same result but
      nothing happens (even no error message).


      If you have any suggestions to solve my problem i was very thankful :)



      Here are my sources:


      web.xml:


      <?xml version="1.0" encoding="UTF-8"?>
      <web-app version="2.5" 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-app_2_5.xsd"> 
          <display-name>Archetype Created Web Application</display-name>
          
          <context-param>
              <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
              <param-value>.xhtml</param-value>
          </context-param>
          
          <context-param>
              <param-name>facelets.DEVELOPMENT</param-name>
              <param-value>true</param-value>
          </context-param>
          
          <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>Faces Servlet</servlet-name>
              <url-pattern>*.jsf</url-pattern>
          </servlet-mapping>
          
          <listener>
              <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
          </listener>
          
      </web-app>



      Bean:


      import org.jboss.seam.annotations.Name;
      
      /**
       *
       * @author josef
       */
      @Name("DataBean")
      public class DataBackingBean {
          public int getNumberOfEmployees() {
              return 23;
          }
          
      
      }




      XHTML:


      <!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:ui="http://java.sun.com/jsf/facelets"
            xmlns:h="http://java.sun.com/jsf/html">
          <body>
              The number of Employees is #{DataBean.numberOfEmployees}.<br/>
          </body>
      </html>



      Components.xml (EMPTY)


      <?xml version="1.0" encoding="UTF-8"?>
      <components xmlns="http://jboss.com/products/seam/components"
                  xmlns:core="http://jboss.com/products/seam/core"
                  xmlns:persistence="http://jboss.com/products/seam/persistence"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation=
                      "http://jboss.com/products/seam/core http://jboss.com/products/seam/core-2.0.xsd 
                       http://jboss.com/products/seam/persistence http://jboss.com/products/seam/persistence-2.0.xsd
                       http://jboss.com/products/seam/components http://jboss.com/products/seam/components-2.0.xsd">
      
      </components>



      I use Maven to build the project and these are the dependencies i added for seam and facelets:


       <dependency>
                  <groupId>com.sun.facelets</groupId>
                  <artifactId>jsf-facelets</artifactId>
                  <version>1.1.14</version>
          </dependency>
          <dependency>
                  <groupId>org.jboss.seam</groupId>
                  <artifactId>jboss-seam</artifactId>
                  <version>2.0.0.GA</version>
          </dependency>
          <dependency>
                  <groupId>org.jboss.seam</groupId>
                  <artifactId>jboss-seam-ui</artifactId>
                  <version>2.0.0.GA</version>
          </dependency>
          <dependency>
                  <groupId>org.jboss.seam</groupId>
                  <artifactId>jboss-el</artifactId>
                  <version>2.0.0.GA</version>
              </dependency>
              <dependency>
                  <groupId>org.hibernate</groupId>
                  <artifactId>hibernate-validator</artifactId>
                  <version>3.0.0.ga</version>
              </dependency>




        • 1. Re: Annotation "@Name" not recognized
          grabnj

          I forgot to say. I am deploying the project to glassfish.


          I do not get error messages and the browser shows the following line:


          The number of Employees is .


          When using the Manged Bean it correctly shows:


          The number of Employees is 23.

          • 2. Re: Annotation "@Name" not recognized
            wrzep

            Do you have seam.properties file in WEB-INF/classes of your war? (or in the root of ear if this is ear)


            -P

            • 3. Re: Annotation "@Name" not recognized
              grabnj

              No i don't.


              What should the content look like. Do i have
              to reference this properties file somewhere?


              Thanks

              • 4. Re: Annotation "@Name" not recognized
                grabnj

                NOW I HAVE A SEAM PROPERTIES FILE :)


                and now i understand that smiley :-P of yours.


                thank you very much of your fast and helpful response :)




                Josef Grabner wrote on Sep 17, 2008 21:02:


                No i don't.

                What should the content look like. Do i have
                to reference this properties file somewhere?

                Thanks


                Click HELP for text formatting instructions. Then edit this text and check the preview.