Issue Details (XML | Word | Printable)

Key: JAVASERVERFACES-2405
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Manfred Riem
Reporter: kwutzke
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
javaserverfaces

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

Created: 02/May/12 01:32 PM   Updated: 24/May/12 06:41 PM   Resolved: 24/May/12 06:41 PM
Component/s: None
Affects Version/s: 2.1.7
Fix Version/s: 2.1.9, 2.2.0-m03

Time Tracking:
Original Estimate: Not Specified
Remaining Estimate: 0 minutes
Remaining Estimate - 0 minutes
Time Spent: 2 days
Time Spent - 2 days

File Attachments: 1. Text File changebundle.txt (69 kB) 24/May/12 02:46 PM - Manfred Riem
2. Zip Archive newfiles.zip (44 kB) 24/May/12 02:46 PM - Manfred Riem

Environment:

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


Tags:
Participants: kwutzke and Manfred Riem


 Description  « Hide

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.



Manfred Riem added a comment - 02/May/12 03:17 PM

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


kwutzke added a comment - 02/May/12 03:28 PM

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">.


Manfred Riem added a comment - 02/May/12 04:31 PM

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


Manfred Riem added a comment - 11/May/12 07:35 PM

Can you supply us with an example application?


kwutzke added a comment - 11/May/12 08:38 PM

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?


kwutzke added a comment - 16/May/12 11:59 AM

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.


Manfred Riem added a comment - 21/May/12 04:58 PM

Can you attach a working Maven project containing an example?


Manfred Riem added a comment - 24/May/12 02:46 PM

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.