4 Replies Latest reply on Dec 18, 2007 4:35 PM by Pete Muir

    Using Seam with Facelets and EL Parameters

    Chuck G Newbie

      I am having an issue with using Seam with passed in Action Parameters in EL. I am tied to WebLogic right now, and hearing about the EJB3 issues that Seam has, I just want to use the UI features of Seam in order to pass parameters to method calls in the EL. I am using Seam 2.0 GA, Facelets 1.1-13, and RichFaces latest release along with the Sun RI Implementation of JSF.

      In a facelets page I have the following code:

      <ui:composition>
      <f:view>
      <s:fragment rendered="#{SecurityManager.isAllowed(View_Position)}">


      This is throwing an exception:
      com.sun.facelets.tag.TagAttributeException: //C:/dev/workspace/AppName/WebContent/WEB-INF/tabs/position.xhtml @15,68 rendered="#{SecurityManager.isAllowed(View_Position)}" Error Parsing: #{SecurityManager.isAllowed(View_Position)}
       at com.sun.facelets.tag.TagAttribute.getValueExpression(TagAttribute.java:259)
       at com.sun.facelets.tag.jsf.ComponentRule$ValueExpressionMetadata.applyMetadata(ComponentRule.java:69)
       at com.sun.facelets.tag.MetadataImpl.applyMetadata(MetadataImpl.java:36)
       at com.sun.facelets.tag.MetaTagHandler.setAttributes(MetaTagHandler.java:62)
       at com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:144)
       at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
       at com.sun.facelets.tag.jsf.core.ViewHandler.apply(ViewHandler.java:109)
      


      My web.xml looks like this:
      <?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>DisplayName</display-name>
      
       <!-- Seam -->
       <listener>
       <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
       </listener>
      
       <servlet>
       <servlet-name>Seam Resource Servlet</servlet-name>
       <servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class>
       </servlet>
      
       <servlet-mapping>
       <servlet-name>Seam Resource Servlet</servlet-name>
       <url-pattern>/seam/resource/*</url-pattern>
       </servlet-mapping>
      
       <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>
      
       <!-- End Seam -->
      
       <!-- JSF -->
       <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>
      
       <context-param>
       <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
       <param-value>.xhtml</param-value>
       </context-param>
      
       <context-param>
       <param-name>facelets.VIEW_MAPPINGS</param-name>
       <param-value>*.jspx;*.xhtml;</param-value>
       </context-param>
      
       <context-param>
       <param-name>facelets.DEVELOPMENT</param-name>
       <param-value>true</param-value>
       </context-param>
      
       <context-param>
       <param-name>facelets.REFRESH_PERIOD</param-name>
       <param-value>2</param-value>
       </context-param>
      
       <context-param>
       <param-name>facelets.LIBRARIES</param-name>
       <param-value>
       /WEB-INF/htmLib.taglib.xml;
       /WEB-INF/facelets/tags/dems.taglib.xml;
       </param-value>
       </context-param>
      
       <!-- RichFaces Configuration -->
      
       <context-param>
       <param-name>org.richfaces.SKIN</param-name>
       <param-value>blueSky</param-value>
       </context-param>
      
       <filter>
       <display-name>Ajax4jsf Filter</display-name>
       <filter-name>ajax4jsf</filter-name>
       <filter-class>org.ajax4jsf.Filter</filter-class>
       </filter>
      
       <filter-mapping>
       <filter-name>ajax4jsf</filter-name>
       <servlet-name>Faces Servlet</servlet-name>
       <dispatcher>REQUEST</dispatcher>
       <dispatcher>FORWARD</dispatcher>
       <dispatcher>INCLUDE</dispatcher>
       </filter-mapping>
      
      
       <!-- End RichFaces Configuration -->
      


      My 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_1_2.xsd"
       version="1.2">
       <application>
       <el-resolver>org.jboss.seam.el.SeamELResolver</el-resolver>
       <locale-config>
       <default-locale>en</default-locale>
       </locale-config>
       <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
       </application>
       </lifecycle>
       <factory>
       <application-factory>com.sun.faces.application.ApplicationFactoryImpl</application-factory>
       <faces-context-factory>com.sun.faces.context.FacesContextFactoryImpl</faces-context-factory>
       <lifecycle-factory>com.sun.faces.lifecycle.LifecycleFactoryImpl</lifecycle-factory>
       <render-kit-factory>com.sun.faces.renderkit.RenderKitFactoryImpl</render-kit-factory>
       </factory>


      It seems that the FaceletViewHandler is still being used to interpret EL expressions. I find documentation relating to Seam 1.1 that refer to a SeamFaceletViewHandler, but that seems to be missing from Seam 2.0. Is there something glaringly obvious I am missing? Please let me know if you need further information regarding my configuration or anything else.

      Thanks!


        • 1. Re: Using Seam with Facelets and EL Parameters
          Dustin Norlander Apprentice

          Looks like your syntax is wrong..

          Things to check

          you have a bean named 'SecurityManager'?
          i.e.

          @Name("SecurityManager")
          


          you have a variable in the current context called "View_Position"?
          That is, assuming you didn't mean to write:

          rendered="#{SecurityManager.isAllowed('View_Position')}">
          




          • 2. Re: Using Seam with Facelets and EL Parameters
            Chuck G Newbie

            Thanks for your response. This is what I get for doing this Friday late in the day :).

            I have a bean named SecurityManager, I omitted the managed beans from my config to save space so my post wasn't too long. It's defined here:

            <managed-bean>
             <managed-bean-name>SecurityManager</managed-bean-name>
             <managed-bean-class>com.cgp.security.SecurityManager</managed-bean-class>
             <managed-bean-scope>request</managed-bean-scope>
             </managed-bean>
            


            I had tried encasing View_Position in both single tick marks and without them, with both not working :( I think the wrong EL interpreter is being used, but I am not sure how to change it.

            Thanks again.

            • 3. Re: Using Seam with Facelets and EL Parameters
              Chuck G Newbie

              I think I may be on to something and I wonder if anyone can clarify this for me a bit. When I removed the following from the faces-config.xml, I got a NoClassDefFoundError, which I found the jar and fixed:

              <factory>
               <application-factory>com.sun.faces.application.ApplicationFactoryImpl</application-factory>
               <faces-context-factory>com.sun.faces.context.FacesContextFactoryImpl</faces-context-factory>
               <lifecycle-factory>com.sun.faces.lifecycle.LifecycleFactoryImpl</lifecycle-factory>
               <render-kit-factory>com.sun.faces.renderkit.RenderKitFactoryImpl</render-kit-factory>
               </factory>
              


              But, when I did that, Ajax4jsf/RichFaces stopped working properly for me and I got a slew of errors such as:
              org.ajax4jsf.resource.ResourceNotFoundException: Resource not registered : org.ajax4jsf.javascript.AjaxScript.jsf
               at org.ajax4jsf.resource.ResourceBuilderImpl.getResource(ResourceBuilderImpl.java:393)
               at org.ajax4jsf.resource.ResourceBuilderImpl.getResourceForKey(ResourceBuilderImpl.java:337)
               at org.ajax4jsf.resource.InternetResourceService.serviceResource(InternetResourceService.java:155)
               at org.ajax4jsf.resource.InternetResourceService.serviceResource(InternetResourceService.java:144)
               at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:265)
               Truncated. see log file for complete stacktrace
              


              and

              org.ajax4jsf.resource.ResourceNotFoundException: Resource not registered : org/richfaces/renderkit/html/scripts/browser_info.js.jsf
               at org.ajax4jsf.resource.ResourceBuilderImpl.getResource(ResourceBuilderImpl.java:393)
               at org.ajax4jsf.resource.ResourceBuilderImpl.getResourceForKey(ResourceBuilderImpl.java:337)
               at org.ajax4jsf.resource.InternetResourceService.serviceResource(InternetResourceService.java:155)
               at org.ajax4jsf.resource.InternetResourceService.serviceResource(InternetResourceService.java:144)
               at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:265)
               Truncated. see log file for complete stacktrace
              


              I think I narrowed it down to the application-factory element. If I omit it, the page I am trying to display comes up, but it's not functional, if I don't, I get an EL-expression error.

              Does anyone have any insight into how I can get Ajax4jsf/RichFaces and the Seam-EL to play nice together? Again, any help is appreciated!

              Cheers.

              • 4. Re: Using Seam with Facelets and EL Parameters
                Pete Muir Master

                Why are you using managed beans with Seam? I suggest you start from the JPA example for WAS.