Infinite loop when in some pages.xml configuration
--------------------------------------------------
Key: JBSEAM-1770
URL:
http://jira.jboss.com/jira/browse/JBSEAM-1770
Project: JBoss Seam
Issue Type: Bug
Affects Versions: 2.0.0.BETA1
Environment: windows XP, RHEL 5.0
Reporter: Richard Leherpeur
You can download this example on the Seam web site: navigation.zip
I have the following classes:
Code:
@Name("user")
@Scope(ScopeType.CONVERSATION)
public class User implements Serializable {
private String pet;
public String getPet() {
return pet;
}
public void setPet(String pet) {
this.pet = pet;
}
}
Code:
@Name("navigation")
@Scope(ScopeType.CONVERSATION)
public class Navigation implements Serializable {
@In(required=true)
User user;
@Logger
private Log log;
public String animalOutcome(){
if (user == null){
return "Dog"; // Just to make sure we don't return null
}
log.info("********* Outcome: " + user.getPet());
return user.getPet();
}
public User getUser() {
return user;
}
public void setUser(User user) {
this.user = user;
}
}
Code:
@Name("animals")
public class AnimalList
{
private List<String> animals;
@Unwrap
public List<String> unwrap()
{
if (animals == null)
{
animals = new ArrayList<String>();
animals.add("Dog");
animals.add("Cat");
animals.add("Goldfish");
animals.add("Rabbit");
animals.add("Snake");
animals.add("Parrot");
}
return animals;
}
}
Pages.xhtml is defined as followed:
Code:
<pages
xmlns="http://jboss.com/products/seam/pages"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.com/products/seam/pages
http://jboss.com/products/seam/pages-2.0.xsd">
<page view-id="/pageOne.xhtml">
<begin-conversation join="true" pageflow="navigation" />
</page>
<page view-id="/animalPage.xhtml"
action="#{navigation.animalOutcome}">
<navigation>
<rule if-outcome="Dog">
<redirect view-id="/animal/dog.xhtml"/>
</rule>
<rule if-outcome="Cat">
<redirect view-id="/animal/cat.xhtml"/>
</rule>
<rule if-outcome="Goldfish">
<redirect view-id="/animal/goldfish.xhtml"/>
</rule>
<rule if-outcome="Rabbit">
<redirect view-id="/animal/rabbit.xhtml"/>
</rule>
<rule if-outcome="Snake">
<redirect view-id="/animal/snake.xhtml"/>
</rule>
<rule if-outcome="Parrot">
<redirect view-id="/animal/parrot.xhtml"/>
</rule>
</navigation>
</page>
</pages>
The pageflow is defined as:
Code:
<pageflow-definition
xmlns="http://jboss.com/products/seam/pageflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://jboss.com/products/seam/pageflow
http://jboss.com/products/seam/pageflow-2.0.xsd"
name="navigation">
<start-page name="displayChoice" view-id="/pageOne.xhtml">
<redirect/>
<transition name="next" to="animalPage" />
</start-page>
<page name="animalPage" view-id="/animalPage.xhtml">
<end-conversation/>
<redirect/>
</page>
</pageflow-definition>
And finally the pageOne.xhtml:
Code:
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:c="http://java.sun.com/jstl/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:s="http://jboss.com/products/seam/taglib">
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=UTF-8" />
<title>Test Navigation</title>
</head>
<body>
<div id="container">
<h3>Choose an animal</h3>
<h:form>
<h:selectOneMenu value="#{user.pet}">
<s:selectItems value="#{animals}" var="animal"
label="#{animal}" noSelectionLabel="Select your pet"/>
</h:selectOneMenu>
<h:commandButton value="Go To Pet Page" action="next" />
</h:form>
</div>
</body>
</html>
When I select an animal, I get the following stacktrace:
Code:
INFO: Added Library from: jar:file:/C:/Jboss/jboss-4.2.0.GA/server/default/tmp/d
eploy/tmp50163navigation.ear-contents/navigation-exp.war/WEB-INF/lib/jsf-facelet
s.jar!/META-INF/jstl-core.taglib.xml
13:23:07,046 INFO [Navigation] ********* Outcome: Cat
13:23:07,218 INFO [Navigation] ********* Outcome: Cat
13:23:07,281 INFO [Navigation] ********* Outcome: Cat
13:23:07,359 INFO [Navigation] ********* Outcome: Cat
13:23:07,437 INFO [Navigation] ********* Outcome: Cat
13:23:07,515 INFO [Navigation] ********* Outcome: Cat
13:23:07,609 INFO [Navigation] ********* Outcome: Cat
13:23:07,687 INFO [Navigation] ********* Outcome: Cat
13:23:07,781 INFO [Navigation] ********* Outcome: Cat
13:23:07,859 INFO [Navigation] ********* Outcome: Cat
1:
Code:
<page view-id="/animalPage.xhtml">
<navigation evaluate="#{navigation.outcome}">
...
where #{navigation.outcome} returns outcome
-> redirection to /animalPage.xhtml (which doesn't exist) because evaluate EL
expression is never called
2:
Code:
<page view-id="/animalPage.xhtml"
action="#{navigation.animalOutcome}">
<navigation evaluate="#{navigation.outcome}">
...
where #{navigation.animalOutcome} returns void and #{navigation.outcome} returns outcome
-> We enter a loop where action expression is called then evaluate expression is
called, etc....
3:
Code:
<page view-id="/animalPage.xhtml"
action="#{navigation.animalOutcome}">
<navigation from-action="#{navigation.animalOutcome}">
...
where #{navigation.animalOutcome} returns outcome
-> We enter a loop where action expression is called indefinitely
4:
Code:
<page view-id="/animalPage.xhtml"
action="#{navigation.animalOutcome}">
<navigation>
...
where #{navigation.animalOutcome} returns outcome
-> We enter a loop where action expression is called indefinitely
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira