4 Replies Latest reply on Sep 13, 2010 8:41 AM by R O

    Urgent Help Please, Suggestion Box

    R O Newbie

      Hello All,

      I am trying to create a dynamic list of input text fields, each one has a suggestion box :

       

      <c:forEach items="${bean.inputList}" var="parameter">
                      <h:inputText id="_${parameter.code}" value="#{parameter.value}"/>
                      <rich:suggestionbox for="_${parameter.code}"
                                          var="result"
                                          nothingLabel="No data"
                                          selfRendered="true"
                                          ajaxSingle="false"
      
                                          suggestionAction="#{bean.autoComplete}">
                          <h:column>
                              <h:outputText value="#{result}"/>
                          </h:column>
                      </rich:suggestionbox>
      </c:forEach>
      
      

      The list used in this loop is populated when the user selects an item from a drop down. So When the user change the selected item , I call rerender on the output panel that contains previous list :

       

      My Problem is on rerender (on the second selection made by the user) I recive the following exception:

       

      com.sun.facelets.FaceletViewHandler handleRenderException
      SEVERE: Error Rendering View
      javax.faces.FacesException: Component for target _1 not found in SuggestionBox j_1_sb
      

       

      Actually the component doesn’t exist because user changes the selection and it will not be included in the new list, so why the suggestion component still there, shouldn’t it be removed?

       

      Thanks

        • 1. Re: Urgent Help Please, Suggestion Box
          Ilya Shaikovsky Master

          use a4j:repeat instead of c:forEach

          • 2. Re: Urgent Help Please, Suggestion Box
            R O Newbie

            Hi LLya, Thanks for your reply,

            I tried using a4j:repeat but I faced a problem in the generated component ID.

             

            For the same previous example using a4j repeate

             

            <a4j:repeat value="${bean.inputList}" var="parameter">
                            <h:inputText id="_${parameter.code}" value="#{parameter.value}"/>
                            <rich:suggestionbox for="_${parameter.code}"
                                                var="result"
                                                nothingLabel="No data"
                                                selfRendered="true"
                                                ajaxSingle="false"
                                                suggestionAction="#{bean.autoComplete}">
                                <h:column>
                                    <h:outputText value="#{result}"/>
                                </h:column>
                            </rich:suggestionbox>
            </a4j:repeat>

             

             

             

            <a4j:repeat value="${bean.inputList}" var="parameter">

                            <h:inputText id="_${parameter.code}" value="#{parameter.value}"/>

             

                            <rich:suggestionbox for="_${parameter.code}"

                                                var="result"

                                                nothingLabel="No data"

                                                selfRendered="true"

                                                ajaxSingle="false"

             

                                                suggestionAction="#{bean.autoComplete}">

             

                                <h:column>

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

                                </h:column>

                            </rich:suggestionbox>

            </a4j:repeat>

             

             

            I get the following error on page start:

             

             

            com.sun.facelets.FaceletViewHandler handleRenderException

            SEVERE: Error Rendering View

            javax.faces.FacesException: Component for target _1 not found in SuggestionBox j_1_sb

             

            When I tried to load the page without suggestion components I found that generated

            component ids doesn't match the value given in the repeat tag , instead it was given a value like 'j_id40:0:_'


            • 3. Re: Urgent Help Please, Suggestion Box
              Ilya Shaikovsky Master

              change to

               

                              <h:inputText id="justPlainShortId" value="#{parameter.value}"/>

               

                              <rich:suggestionbox for="justPlainShortId"

              • 4. Re: Urgent Help Please, Suggestion Box
                R O Newbie

                Thanks Ilya, It is now working