This content has been marked as final.
Show 3 replies
-
1. Re: java.lang.StackOverflowError Evaluate Expression in Constructor
manarh May 15, 2015 7:25 AM (in response to vata2999)Please provide more details like Seam annotations on ProjectFilter class or show your error stack trace.
-
2. Re: java.lang.StackOverflowError Evaluate Expression in Constructor
vata2999 May 15, 2015 10:43 AM (in response to manarh)I looked at Seam EntityQuery and I think this is by design even EntityQuery evaluates Expressions after you call getResultList() method so it is impossible to evaluate expressions in Constructor.
is this correct ?
@Name("projectFilter") @Scope(Scope.Conversation) public class ProjectFilter implements Serializable{ private ProjectFilterParameters projectFilterParameters = new ProjectFilterParameters(); public ProjectFilterParameters getProjectFilterParameters(){ return projectFilterParameters; } public ProjectFilter(){ System.out.println(Expressions.instance().createValueExpression("#{projectFilter.projectFilterParameters.program1Id}").getValue()) // cause stackoverflow } }
public class ProjectFilterParameters implements Serializable { private Long program1Id; public void setProgram1Id(long program1Id){ this.program1Id = program1Id; } public long getProgram1Id(){ return program1Id; } }
<param name="program1Id" value="#{projectFilter.projectFilterParameters.program1Id}"/>
<h:form> <h:inputText value="#{projectFilter.projectFilterParameters.program1Id}" id="program1Id" /> <h:commandButton value="Search" action="/projectFilter.xhtml" /> </h:form>
-
3. Re: java.lang.StackOverflowError Evaluate Expression in Constructor
manarh May 15, 2015 11:31 AM (in response to vata2999)yep, I didn't realized that you are cycling in the same constructor like you are evaluating in the expression.
the #{projectFilter} will try to find existing instance of ProjectFilter and if that is not found it will call its constructor so that's why you get stackoverflow.