5 Replies Latest reply on Oct 20, 2009 8:28 PM by Marcos Rivas

    How to disable richfaces:suggestionBox?

    Michael Griffith Newbie

      Hi,


      I have some users that are annoyed by the richfaces:suggestionBox popup within my application. I'd like to be able to provide a checkbox on the search form and allow them to disable it.  I've tried using a Javascript function to set the disabled property of the suggestionBox.  It didn't produce any errors, but it also didn't work either.



      |        <script type="text/javascript">
                  //<![CDATA[
                  
                  function useSuggestion(){
                      var suggest= document.getElementById("actionSearch:useSuggestions");
                      if(!accept.checked){
                          return false;
                      }
                      return true;
                  }
                  
                  // ]]>
              </script>  
      
      
      
                      <rich:suggestionbox id="pointPersonSuggestionBoxId" ajaxSingle="true" width="500" height="300" minChars="4" disabled="javascript:useSuggestion();"
                       for="pointPerson" suggestionAction="#{suggestBox.suggestActionPointPerson}" var="anAction">
                           <h:column> 
                              <h:outputText value="#{anAction}" />
                           </h:column>
                     </rich:suggestionbox>
      |



      Is this possible?  Can someone point me to an example?


      Thanks in advance!
      MG

        • 1. Re: How to disable richfaces:suggestionBox?
          James Kelly Newbie

          It might be easier to use Ajax4JSF than to do this on the client side:


          <a4j:outputPanel id="suggestionPanel" >
              <h:selectBooleanCheckbox  id="disableCheckBox" value="#{example.suggestionDisabled}" >
                  <a4j:support reRender="suggestionPanel" event="click"/>
              </h:selectBooleanCheckbox>
              <h:outputText value="Disable auto suggest?"/>
          
              <rich:suggestionbox id="pointPersonSuggestionBoxId" ajaxSingle="true" width="500" height="300" minChars="4" disabled="#{example.suggestionDisabled}" for="pointPerson" suggestionAction="#{suggestBox.suggestActionPointPerson}" var="anAction">
                  <h:column> 
                      <h:outputText value="#{anAction}" />
                  </h:column>
              </rich:suggestionbox>
          </a4j:outputPanel>
          



          The example component in this case has a single boolean property suggestionDisabled to store the disabled state of the suggestion box.

          • 2. Re: How to disable richfaces:suggestionBox?
            James Kelly Newbie

            Er, the event attribute on that a4j:support element is probably wrong. It might need to be onclick.

            • 3. Re: How to disable richfaces:suggestionBox?
              Michael Griffith Newbie

              James,


              Thanks for the reply.  When I try to use the suggestionbox insude of the a4j:outputPanel, the suggestionProperty is not found. I get an exception like:



              javax.el.PropertyNotFoundException: Property 'suggestActionPointPerson' not found on type org.javassist.tmp.java.lang.Object_$$_javassist_7
                      at javax.el.BeanELResolver$BeanProperties.get(BeanELResolver.java:193)
                      at javax.el.BeanELResolver$BeanProperties.access$400(BeanELResolver.java:170)
                      at javax.el.BeanELResolver.property(BeanELResolver.java:279)
                      at javax.el.BeanELResolver.getValue(BeanELResolver.java:60)
                      at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:53)
                      at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
              


              Your approach seems like the right way to go about this, Any idea what the exception is about? 



              James Kelly wrote on May 09, 2008 02:33 AM:


              It might be easier to use Ajax4JSF than to do this on the client side:

              <a4j:outputPanel id="suggestionPanel" >
                  <h:selectBooleanCheckbox  id="disableCheckBox" value="#{example.suggestionDisabled}" >
                      <a4j:support reRender="suggestionPanel" event="click"/>
                  </h:selectBooleanCheckbox>
                  <h:outputText value="Disable auto suggest?"/>
              
                  <rich:suggestionbox id="pointPersonSuggestionBoxId" ajaxSingle="true" width="500" height="300" minChars="4" disabled="#{example.suggestionDisabled}" for="pointPerson" suggestionAction="#{suggestBox.suggestActionPointPerson}" var="anAction">
                      <h:column> 
                          <h:outputText value="#{anAction}" />
                      </h:column>
                  </rich:suggestionbox>
              </a4j:outputPanel>
              



              The example component in this case has a single boolean property suggestionDisabled to store the disabled state of the suggestion box.


              Click HELP for text formatting instructions. Then edit this text and check the preview.

              • 4. Re: How to disable richfaces:suggestionBox?
                Michael Griffith Newbie

                James,


                I had a typo on my component/attribute name.  Your suggestion works great, thanks for such a GOOD example.


                Cheers!


                MG

                • 5. Re: How to disable richfaces:suggestionBox?
                  Marcos Rivas Newbie

                  Hello there,


                     I'm trying to disable rich:suggestionBox for exactly the same reason and I found this thread, but there is one thing I'm confused about.
                  You are talking about a disabled property on the rich:suggestionBox which does not exists for as much as my research lead me to.  So I'd like to ask you What version of richfaces are you using??? Did you tune up or modified anything to get it?? Am I missing something too obvious here??? 
                     I'll appreciate any help here and thank you in advance.


                  MR