[jboss-user] [JBoss Seam] - Component bindings in Conversation scope

quilleashm do-not-reply at jboss.com
Mon Dec 18 15:00:34 EST 2006


I think I'm correct in saying that currently you cannot have a conversation scoped component that has UIComponent bindings.

e.g. of a minimal example

Facelet view


  | <!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:ui="http://java.sun.com/jsf/facelets">
  |   <head>
  |     <title></title>
  |   </head>
  |   <body>
  |     <h:form>
  |       <h:outputText value="Text" binding="#{testBean.outputText}"/>
  | 
  |       <h:commandButton value="Submit"/>
  |     </h:form>
  |   </body>
  | </html>
  | 

And the bean


  | @Name( "testBean" )
  | @Scope( ScopeType.CONVERSATION )
  | public class TestBean
  | {
  |     private HtmlOutputText outputText;
  | 
  |     public HtmlOutputText getOutputText()
  |     {
  |         return outputText;
  |     }
  | 
  |     public void setOutputText( HtmlOutputText outputText )
  |     {
  |         this.outputText = outputText;
  |     }
  | }
  | 

It is fine during the initial rendering of the page but if you click the button to do a postback the setOutputText() is called during the restore view phase which is before the conversation context is created by Seam (done in the afterPhase() of the restore view), so the component is unavailable.

For completeness here's the exception.


  | javax.el.PropertyNotFoundException: /index.xhtml @11,68 binding="#{testBean.outputText}": Target Unreachable, identifier 'testBean' resolved to null
  | 	at com.sun.facelets.el.TagValueExpression.setValue(TagValueExpression.java:95)
  | 	at com.sun.faces.lifecycle.RestoreViewPhase.doPerComponentActions(RestoreViewPhase.java:228)
  | 	at com.sun.faces.lifecycle.RestoreViewPhase.doPerComponentActions(RestoreViewPhase.java:233)
  | 	at com.sun.faces.lifecycle.RestoreViewPhase.doPerComponentActions(RestoreViewPhase.java:233)
  | 	at com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:186)
  | 	at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:248)
  | 	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.internalDoFilter(ApplicationFilterChain.java:290)
  | 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
  | 	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:228)
  | 	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
  | 	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
  | 	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
  | 	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
  | 	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:212)
  | 	at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:818)
  | 	at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:624)
  | 	at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:445)
  | 	at java.lang.Thread.run(Thread.java:595)
  | 

The short term workaround would be to put component bindings in an event scoped component and inject it into the conversation component but I'd prefer not to do this.

Is it possible via some configuration/option to allow this particular combination?  I looked at the SeamPhaseListener and it would be trivial to move the conversation setup code into the beforePhase() of restore view but I have no idea what side-effects this will have and if it will work.

Is the conversation setup done after restore view for a particular reason? Would be very useful to me personally as I think I will frequently need to bind UI components to do certain types of dynamic page creation in the code. I'm willing to spend some time looking at/trying this if it's worth investigating a change.

Cheers.

Mike.


View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3994781#3994781

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3994781



More information about the jboss-user mailing list