4 Replies Latest reply on Oct 28, 2009 9:23 AM by xilosh

    a4j:JSfunction a4j:coomandButton different different behavio

    xilosh

      Hi all,
      The richfaces documentation says that in documentation says that it's possible to use <a4j:jsFunction> instead of <a4j:commandButton>, but it is not working for me.
      I'm invoking an actionListener using a4j:commandButton, the action do a search and prints the number of results, works fine. Currently I want to use a4j:JSfunction to invoke the same action, the action is invoked and the search is done properly, however results display 0 elements found, I'm debbuging at server and results are found. The action invoked is the same in both cases,
      Here is my code
      jsp page

      <?xml version="1.0" encoding="iso-8859-1" ?>
      <jsp:root version="1.2" xmlns:jsp="http://java.sun.com/JSP/Page"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:c="http://java.sun.com/jsp/jstl/core"
       xmlns:rich="http://richfaces.org/rich"
       xmlns:a4j="http://richfaces.org/a4j">
       <jsp:directive.page contentType="text/html;charset=iso-8859-1"
       pageEncoding="iso-8859-1" />
       <f:view>
       <html lang="es">
       <body>
       <a4j:form id="formulario">
       <script>
       function search(){
       updateGraph(); }
       </script>
       <h:inputText id="content"
       binding="#{interfaceContainer.documentFormContainer.inputTexts['content']}"/>
       <a4j:jsFunction name="updateGraph" actionListener="#{interfaceContainer.documentFormActions.search}" >
       </a4j:jsFunction>
       <a4j:commandButton type="submit" tabindex="80"
       title="buscar" value="Buscara4j" id="Submit" actionListener="#{interfaceContainer.documentFormActions.search}" />
       <h:commandButton tabindex="80" title="update"
       id="updateGrgg" value="graph" onclick="javascript:search();" />
       <a4j:outputPanel>
       <h:outputText id="info2"
       value="Empty #{not empty searchResults} number #{searchResults.numFound } " />
       </a4j:outputPanel>
       </a4j:form>
       </body>
       </html>
       </f:view>
      </jsp:root>
      


      The beans scope of the beans is request, and the action is
      
       public void search(ActionEvent e) {
      
       FacesContext context = FacesContext.getCurrentInstance();
       SearchResults searchResults = (SearchResults) context.getELContext()
       .getELResolver().getValue(context.getELContext(), null,
       "searchResults");
       QResponse qresponse = solrConnector.executeSearch();
      
       processSearch(qresponse, searchResults);
       context.getELContext()
       .getELResolver().setValue(context.getELContext(), null,
       "searchResults",searchResults);
       }