Factory method - how many times it should be called?
zeppelinux.dmitry.diligesoft.com Oct 11, 2009 10:44 AMHi,
Have spent the whole day in debugger and still can't figure out why my @Factory method called twice during rendering of the same page.
The request is started by s:link :
`
<s:link view="someViewId" propagation="begin">
<f:param name="param1" value="val1"/>
`
The 'someViewId' doesn't have any page action or navigation rule
Action component with the Factory method is defined as follows:
`
`
The data is just some entity loaded from db.
I can see there are two org.jboss.seam.contexts.ServerConversationContext created during the request processing, so the Factory method is invoked for each of them (and 'data' is looked up and loaded for each of them too).
Stack for both times the context is created is identical (the phase is RESTORE_VIEW):
`@Name("taskAction")
@Scope(ScopeType.CONVERSATION)
public class SomeViewAction {
@Out(required = false)
SomeEntity data;
@Factory("data")
public void loadData(){
//load data from database
....
}
}`
The stack for both contexts creation is identical (both at the same RESTORE_VIEW phase)
at org.jboss.seam.contexts.ServerConversationContext.<init>(ServerConversationContext.java:72)
at org.jboss.seam.contexts.FacesLifecycle.resumeConversation(FacesLifecycle.java:169)
at org.jboss.seam.jsf.SeamPhaseListener.afterRestoreView(SeamPhaseListener.java:393)
at org.jboss.seam.jsf.SeamPhaseListener.afterServletPhase(SeamPhaseListener.java:230)
at org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:196)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:280)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:317)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java)
The second context is created at the very end of request processing (when the page is already rendered in the browser, so question is what happened with the first conversation context? Why it became obsolete or forgotten?
Thanks
Have spent the whole day in debugger and still can't figure out why my @Factory method called twice during rendering of the same page.
The request is started by s:link :
`
<s:link view="someViewId" propagation="begin">
<f:param name="param1" value="val1"/>
`
The 'someViewId' doesn't have any page action or navigation rule
Action component with the Factory method is defined as follows:
`
`
The data is just some entity loaded from db.
I can see there are two org.jboss.seam.contexts.ServerConversationContext created during the request processing, so the Factory method is invoked for each of them (and 'data' is looked up and loaded for each of them too).
Stack for both times the context is created is identical (the phase is RESTORE_VIEW):
`@Name("taskAction")
@Scope(ScopeType.CONVERSATION)
public class SomeViewAction {
@Out(required = false)
SomeEntity data;
@Factory("data")
public void loadData(){
//load data from database
....
}
}`
The stack for both contexts creation is identical (both at the same RESTORE_VIEW phase)
at org.jboss.seam.contexts.ServerConversationContext.<init>(ServerConversationContext.java:72)
at org.jboss.seam.contexts.FacesLifecycle.resumeConversation(FacesLifecycle.java:169)
at org.jboss.seam.jsf.SeamPhaseListener.afterRestoreView(SeamPhaseListener.java:393)
at org.jboss.seam.jsf.SeamPhaseListener.afterServletPhase(SeamPhaseListener.java:230)
at org.jboss.seam.jsf.SeamPhaseListener.afterPhase(SeamPhaseListener.java:196)
at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:280)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)
at org.apache.catalina.core.ApplicationFilterChain.servletService(ApplicationFilterChain.java:411)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:317)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:198)
at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java)
The second context is created at the very end of request processing (when the page is already rendered in the browser, so question is what happened with the first conversation context? Why it became obsolete or forgotten?
Thanks