1 Reply Latest reply on Jul 30, 2009 3:54 PM by bossy

    Problem with Ajax command and Seam component scope

    bossy

      Hello,


      I hope that this is the correct place to ask this question, although I realise some of it may be related to Richfaces.


      In my form I have a field that I use for lookup in another system ( via http request) and populate some of the other fields of the form with the results of that search.


      The way I implemented this in to have an a4j:commandButton in my form calling the search action. The search result is then displayed in a rich:dataTable.


      I have a rich:datascroller that allows me to scroll the table if the number of result items exceeds the rows of the table.


      The problem is that if my search action is in scope EVENT , the scrolling doesn't work. If I change the scope to CONVESRATION - I can scroll, but I cannot perform subsequent searches.


      I thought of using nested conversation, but the documentation says: A nested conversation has its own conversation context, and also has read-only access to the context of the outer conversation. (It can read the outer conversation's context variables, but not write to them.).
      That to me means that I cannot populate the fields of the form with the result of that search.


      Below are some excerpts from my code


      My form:




      <a:region>
       <s:decorate id="field1" >
                    
       <h:inputText id="f1"  immediate="true"
            value="#{myEntHome.instance.field1}" >
            <a:support event="onblur" reRender="field1"  />                   
       </h:inputText>
                
       <a:commandButton value="Lookup" image="img/search.GIF" ajaxSingle="true" 
            id="searchImg" action="#{searchAction.search}"   reRender="myModPanel,field2,field3"
           oncomplete="Richfaces.showModalPanel('searchResult')">                            
       </a:commandButton>
       </s:decorate>
      </a:region>
      
      <h:inputText id="f2"  immediate="true"
            value="#{myEntHome.instance.field2}" >
           <a:support event="onblur" reRender="field2"  />                   
      </h:inputText>/a:region>
      <h:inputText id="f3"  immediate="true"
           value="#{myEntHome.instance.field3}" >
             <a:support event="onblur" reRender="field3"  />                   
      </h:inputText>




      in my searchResult modalPanel I have:
         




      <rich:datascroller for="pl" ajaxSingle="true" >
      
      <rich:dataTable id="pl"    var="_pl" value="#{resultList}"  >             
            <h:column>
                <f:facet name="header">
                    <h:outputText value="Criteria"/>
                </f:facet>
                <h:outputText value="#{_pl.criteria}"/><br/> 
            </h:column>               
      </rich:dataTable>




           
      and my search action looks like this:




      @Name("searchAction")
      @Scope(ScopeType.EVENT)     
      public class mySearchAction
      {
             @DataModel
            List<MyResultItem> resultList;
            
           public void search()
           {
              resultList = something;     
           }
           
      }
      



      Could anyone suggest an approach for solving this problem.


      Thanks.