0 Replies Latest reply on Sep 1, 2011 5:14 AM by sebastian_goetz

    rich:autocomplete do submit on item selection

    sebastian_goetz

      Hi all,

       

      I have a little problem using the rich:autocomplete component.

      What I planned was, that the user enters some search phrase and selects a suggestion in one form. Upon that selection the form is submitted and the data for that selected item is shown on the page in a second form. It should work like an ajax search. This is what I have achieved so far:

       

      <ui:define name="content">

          <h:form>

              <h:inputText id="preventPageReloadOnFormSubmitIE" value="Fix IE bug" style="display:none;" />

              <rich:panel id="searchPanel" header="#{tr.lbl_search}">

                  <rich:tooltip mode="client" followMouse="false" showDelay="700" layout="block">

                      <h:outputText value="#{tr.tip_ajaxSearch}"/>

                  </rich:tooltip>

                 

                  <a4j:jsFunction name="doSearchCustomer" execute="ajaxSearch" render="customerForm"

                      actionListener="#{customerBean.doSearch}"/>

                  <rich:autocomplete id="ajaxSearch" mode="cachedAjax" minChars="2"

                      autocompleteMethod="#{customerBean.autocomplete}" autofill="true"

                      var="customer" fetchValue="#{customer.name}" immediate="true"

                      layout="grid" value="#{customerBean.searchPhrase}"

                      onselectitem="doSearchCustomer();">

                      <h:outputText value="#{customer.name} #{prm:enclose(customer.addressesList[0].city, '(', ')')}" />

                  </rich:autocomplete>

              </rich:panel>

          </h:form>

          <br/>

          <h:form id="customerForm">

              <rich:panel rendered="#{not empty customerBean.customer and not customerBean.customer.transient}">

                ...

       

      This works quite fine and data is shown as expected. Now the strange thing is, that when the page is shown, the command buttons in the form 'customerForm' are not working as expected. There are several of them for different actions but neither is working. The first time I click one of them, the customerForm is submitted with no action and the page is rebuild. After that all buttons work fine. Is there a problem with the initial ajax request, when the search data is send?

      I already wanted to replace the a4j:jsFunction with a real form submit (non-Ajax) but I found no solution for that. Can anyone help me out, please?

       

      Regards,

       

      Sebastian