[jboss-user] [JBoss Seam] - Re: Event scoped component accessing Conversion scope

quilleashm do-not-reply at jboss.com
Wed Dec 13 05:34:19 EST 2006


Done some more investigation into this.  I have a minimal test case.

JSF page


  | <?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:ui="http://java.sun.com/jsf/facelets"
  |       xmlns:f="http://java.sun.com/jsf/core"
  |       xmlns:h="http://java.sun.com/jsf/html">
  |   <head>
  |     <title>Element Name Search</title>
  |   </head>
  |   <body>
  |     <h:form>
  |       <h:inputText value="#{elementSearchAction.searchString}" binding="#{elementSearchAction.searchStringInput}" />
  |       <h:commandButton value="Search" action="#{elementSearchAction.find}"/>
  |     </h:form>
  |   </body>
  | </html>
  | 

Action component


  | @Name( "elementSearchAction" )
  | @Scope( ScopeType.EVENT )
  | public class ElementSearchAction
  | {
  |     @In( create = true )
  |     private Session referenceSession;
  | 
  |     private String searchString = "";
  | 
  |     private UIInput searchStringInput;
  | 
  |     public void find()
  |     {
  |         referenceSession.createQuery( "from Element where eltName like :eltName" ).setParameter( "eltName", searchString + "%" ).list();
  |     }
  | 
  |     public String getSearchString()
  |     {
  |         return searchString;
  |     }
  | 
  |     public void setSearchString( String searchString )
  |     {
  |         this.searchString = searchString;
  |     }
  | 
  |     public UIInput getSearchStringInput()
  |     {
  |         return searchStringInput;
  |     }
  | 
  |     public void setSearchStringInput( UIInput searchStringInput )
  |     {
  |         this.searchStringInput = searchStringInput;
  |     }
  | }
  | 

The problem happens when a post-back is done to the page (hit the search button) and the restore view phase calls through to setSearchStringInput() to bind the control to the bean.  At this point the Seam bijection interceptor jumps in and tries to populate the referenceSession but because the conversation context is not active yet it fails to do this.

Removing the binding of the input control and the form works fine on a post-back.

Changing the action to be conversation scoped gives this..


  | binding="#{elementSearchAction.searchStringInput}": Target Unreachable, identifier 'elementSearchAction' resolved to null
  | 

presumably because the restore view phase is trying to do this binding but the conversation scope is not active yet.

I definately need to bind controls into the beans to do dynamic manipulation of controls.  Do I need to rethink my component structure?  Or something else?  Is deferring seam bijection until after the restore view phase a possibility?

Cheers.

Mike.

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

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



More information about the jboss-user mailing list