1 Reply Latest reply on Dec 30, 2010 8:25 AM by Ilya Shaikovsky

    Problem with Dependent suggestion boxes

    Dhivya S.T Newbie

      Can someone please tell me how to fix the following issue.


      I have two suggestion boxes , Company and Stock key . They are dependent on each other. On selecting Company , it should auto populate text field of the stock key suggestion box with the stock key, similarly if stock key is selected from the suggestion box it should auto populate the text field of company suggestion box.


      I am not able to achieve this with a4j support onselect event , rerender attribute.Moreover if the cmpnt id is given in the rerender attribute of a another cmpnt, after trying if it auto populates, it fails to work as a suggestion box.


      For example: Stock key is given as one of the cmpnts to be rerendered for company , select one value from the suggestion box for company, after this stock key fails to work as a suggestion box. it works like a ordinary text field.


      Find below my code.



            <td align="right" width="17%"><h:outputText value="Stock Key: " /></td>

            <td align="left" width="30"><h:inputText id="trgtStkKey" valueChangeListener="#{NewMergerBean.processValueChangeforTrgtStock}"/>

            <rich:suggestionbox for="trgtStkKey" minChars="3" suggestionAction="#{NewMergerBean.stkKeysuggest}" var="stockKeys">


                        <h:outputText value="#{stockKeys}"></h:outputText>


            <a4j:support event="onselect" action="#{NewMergerBean.populateForTrgtStock}      reRender="trgtCompany,trgtCountry,trgtExch,trgtGICS,trgtTicker,trgtPrice"/>




            <td align="right"><h:outputText value="Target Company: " /></td>

            <td align="left"><h:inputText id="trgtCompany" valueChangeListener="#{NewMergerBean.processValueChangeforTrgtComp}"/>

            <rich:suggestionbox for="trgtCompany" minChars="3" suggestionAction="#{NewMergerBean.companySuggest}" var="companyNames"

                                                      nothingLabel="Company does not exist">


                        <h:outputText value="#{companyNames}"></h:outputText>


            <a4j:support event="onselect" action="#{NewMergerBean.populateForTrgtCompany}"                        reRender="trgtStkKey,trgtCountry,trgtExch,trgtGICS,trgtTicker,trgtPrice"/>



        • 1. Re: Problem with Dependent suggestion boxes
          Ilya Shaikovsky Master

          The problem appears because you reRender only inputText. suggestionBox client Object getting attached to input so when you replacing input DOM element with another one it getting broken.


          The second problem - make both a4j:supports ajaxSingle. In other case both inputs getting submitted and update dependent input with value set from action will fails.