javaserverfaces
  1. javaserverfaces
  2. JAVASERVERFACES-2405

Seam 3 Faces viewAction causes JSF "The form component needs to have a UIForm in its ancestry. Suggestion: enclose the necessary components within <h:form> " in javax.faces Development mode

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1.7
    • Fix Version/s: 2.1.9, 2.2.0-m03
    • Component/s: None
    • Labels:
      None
    • Environment:

      JBoss AS 7.1.1.Final, Mojarra 2.1.7, Seam 3.1.0.Final

      Description

      I have a test page with a @ViewScoped bean:

      <?xml version="1.0" encoding="UTF-8"?>
      <!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:f="http://java.sun.com/jsf/core"
            xmlns:h="http://java.sun.com/jsf/html"
            xmlns:s="http://jboss.org/seam/faces">
      
        <f:metadata>
          <f:viewParam name="id" value="#{nodeManager.id}" required="#{not facesContext.postback}">
            <f:convertNumber integerOnly="#{true}" />
          </f:viewParam>
          <s:viewAction action="#{nodeManager.init}" />
        </f:metadata>
      
        <h:head>
        </h:head>
        
        <h:body>
          BODY
        </h:body>
      </html>

      This causes a Faces message to be appended to the end of the page saying:

      "The form component needs to have a UIForm in its ancestry. Suggestion: enclose the necessary components within <h:form>"

      Issue has been discussed in the Seam 3 forum and on the Seam 3 dev IRC channel:

      https://community.jboss.org/thread/199024

      http://echelog.com/logs/browse/seam-dev/1312322400

      The issue goes away when setting to Production in web.xml, so it appears to be a JSF issue.

        Activity

        Hide
        Manfred Riem added a comment -

        Can you also reproduce the problem without Seam in the picture? That would help us diagnosing the problem a lot.

        Show
        Manfred Riem added a comment - Can you also reproduce the problem without Seam in the picture? That would help us diagnosing the problem a lot.
        Hide
        kwutzke added a comment -

        Not that I know of. I've been using JSF 2.1.7 for several weeks now on quite some complex pages and I've never had any troubles with JSF messages until I added the <s:viewAction> tag to replace the <f:event type="preRenderView">.

        Show
        kwutzke added a comment - Not that I know of. I've been using JSF 2.1.7 for several weeks now on quite some complex pages and I've never had any troubles with JSF messages until I added the <s:viewAction> tag to replace the <f:event type="preRenderView">.
        Hide
        Manfred Riem added a comment -

        Lowering the priority of this issue since it only shows up when setting Mojarra to ProjectStage.Development.

        Show
        Manfred Riem added a comment - Lowering the priority of this issue since it only shows up when setting Mojarra to ProjectStage.Development.
        Hide
        Manfred Riem added a comment -

        Can you supply us with an example application?

        Show
        Manfred Riem added a comment - Can you supply us with an example application?
        Hide
        kwutzke added a comment -

        For which server? I currently use JBoss AS 7, but basically all you need here is a bean like (and not even all of that):

        package what.ever.you.need;
        
        import java.io.Serializable;
        
        import javax.annotation.PostConstruct;
        import javax.faces.bean.ViewScoped;
        import javax.inject.Named;
        
        import org.slf4j.Logger;
        import org.slf4j.LoggerFactory;
        
        @Named
        @ViewScoped
        public class NodeManager implements Serializable
        {
        	private static final Logger log = LoggerFactory.getLogger(NodeManager.class);
        
        	private Integer pqId;
        
        	// JSF PROCESS_VALIDATIONS phase
        	@PostConstruct
        	public void construct()
        	{		
        		log.info(" [1] @PostConstruct on " + getClass().getSimpleName());
        	}
        	
        	public Integer getPqId()
        	{
        		return pqId;
        	}
        	
        	// JSF UPDATE_MODEL_VALUES phase
        	public void setPqId(Integer pqId)
        	{
        		log.info(" [2] Storing mandatory GET param from URL for " + getClass().getSimpleName() + ": pq=" + pqId);
        		
        		this.pqId = pqId;
        	}
        	
        	// JSF INVOKE_APPLICATION phase
        	public void init()
        	{
        		log.info(" [3] Calling init() on " + getClass().getSimpleName());		
        		
        	}
        }

        relevant pom.xml:

          ...
          <dependencyManagement>
            <dependencies>
              ...
              <dependency>
                <groupId>org.jboss.seam</groupId>
                <artifactId>seam-bom</artifactId>
                <version>3.1.0.Final</version>
                <type>pom</type>
                <scope>import</scope>
              </dependency>
            </dependencies>
          </dependencyManagement>
          <dependencies>
            ...
            <dependency>
               <groupId>org.jboss.seam.faces</groupId>
               <artifactId>seam-faces</artifactId>
            </dependency>
            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-jdk14</artifactId>
                <version>1.6.4</version>
                <scope>provided</scope> <!-- Hibernate only -->
            </dependency>
          </dependencies>
        </project>
        

        The SLF4J dep is only optional, remove it as needed.

        Is that sufficient?

        Show
        kwutzke added a comment - For which server? I currently use JBoss AS 7, but basically all you need here is a bean like (and not even all of that): package what.ever.you.need; import java.io.Serializable; import javax.annotation.PostConstruct; import javax.faces.bean.ViewScoped; import javax.inject.Named; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @Named @ViewScoped public class NodeManager implements Serializable { private static final Logger log = LoggerFactory.getLogger(NodeManager.class); private Integer pqId; // JSF PROCESS_VALIDATIONS phase @PostConstruct public void construct() { log.info( " [1] @PostConstruct on " + getClass().getSimpleName()); } public Integer getPqId() { return pqId; } // JSF UPDATE_MODEL_VALUES phase public void setPqId( Integer pqId) { log.info( " [2] Storing mandatory GET param from URL for " + getClass().getSimpleName() + ": pq=" + pqId); this .pqId = pqId; } // JSF INVOKE_APPLICATION phase public void init() { log.info( " [3] Calling init() on " + getClass().getSimpleName()); } } relevant pom.xml: ... <dependencyManagement> <dependencies> ... <dependency> <groupId>org.jboss.seam</groupId> <artifactId>seam-bom</artifactId> <version>3.1.0.Final</version> <type>pom</type> <scope> import </scope> </dependency> </dependencies> </dependencyManagement> <dependencies> ... <dependency> <groupId>org.jboss.seam.faces</groupId> <artifactId>seam-faces</artifactId> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-jdk14</artifactId> <version>1.6.4</version> <scope>provided</scope> <!-- Hibernate only --> </dependency> </dependencies> </project> The SLF4J dep is only optional, remove it as needed. Is that sufficient?
        Hide
        kwutzke added a comment -

        Note, the very same test page on another computer with the same environment (JBoss AS 7.1.1.Final, Mojarra 2.1.7, Seam 3.1.0.Final) spits out another message instead:

        The button/link/text component needs to have a Form in its ancestry. Please add <h:form>.

        Strange stuff.

        Show
        kwutzke added a comment - Note, the very same test page on another computer with the same environment (JBoss AS 7.1.1.Final, Mojarra 2.1.7, Seam 3.1.0.Final) spits out another message instead: The button/link/text component needs to have a Form in its ancestry. Please add <h:form>. Strange stuff.
        Hide
        Manfred Riem added a comment -

        Can you attach a working Maven project containing an example?

        Show
        Manfred Riem added a comment - Can you attach a working Maven project containing an example?
        Hide
        Manfred Riem added a comment -

        Check if a component that needs a form is embedded in one, and if it does then add a global message to the page. Note that the facets of UIViewRoot are skipped, only its children are taken into account.

        Show
        Manfred Riem added a comment - Check if a component that needs a form is embedded in one, and if it does then add a global message to the page. Note that the facets of UIViewRoot are skipped, only its children are taken into account.

          People

          • Assignee:
            Manfred Riem
            Reporter:
            kwutzke
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Time Tracking

              Estimated:
              Original Estimate - Not Specified
              Not Specified
              Remaining:
              Remaining Estimate - 0 minutes
              0m
              Logged:
              Time Spent - 2 days
              2d