6 Replies Latest reply on Mar 25, 2009 8:20 AM by eunnini

    Bug with suggestionBox in Opera 9.2x

      Hi all,

      I'm not sure if this is a bug, but here is the problem:

      
      <h:form id="ajaxForm">
       <rich:suggestionbox id="suggestion1" width="200" height="200" for="title" suggestionAction="#{suggestionBean.autocomplete}" var="suggestion">
       <h:column>
       <h:outputText value="#{suggestion}"/>
       </h:column>
       </rich:suggestionbox>
      </h:form>
      
      <h:form id="htmlForm">
       <h:inputText value="#{suggestionBean.enteredValue}" id="title" />
       <h:commandButton value="search" id="search" action="#{suggestionBean.refresh}" title="search" styleClass="imgButton" />
      </h:form>
      
      


      This is just an example page with input text field, submit button and suggestionBox.
      In Firefox everything works normal, entering something in input produces
      suggestionBox, selecting something and clicking "search" button triggers http request,
      and the browser renders the result page.

      But in Opera, as soon something other than the first item in suggestion box is selected,
      the submit button gets DISABLED or at least it behaves as a disabled button.
      Error console in opera reports no Javascript errors.

      If needed, I can send the test app .war file.

      Thanks in advance,
      Milan


        • 1. Re: Bug with suggestionBox in Opera 9.2x
          eunnini

          I have the same problem that has definitely not solved even in 9.64, check this - it simply does not work in Opera!

          
          <h:form>
          
          <h:panelGroup id="wrappedPanel">
           <h:inputText id="name" value="#{userSession.selectInput}"/>
           <rich:suggestionbox popupClass="sugPopup" for="name"
           suggestionAction="#{userSession.autocompleteNames}" var="result"
           minChars="3" shadowOpacity="4" border="1" width="250" height="250" shadowDepth="4"
           selectedClass="sugSelection" usingSuggestObjects="true">
           <a4j:support event="onselect" actionListener="#{userSession.suggestSelected}"/>
           <h:column>
           <h:outputText value="#{result}" />
           </h:column>
           </rich:suggestionbox>
          </h:panelGroup>
          <h:panelGrid columns="1" id="table">
           <h:commandButton action="#{userSession.test}" value="Submit" />
          </h:panelGrid>
          
           </h:form>
          
          


          • 2. Re: Bug with suggestionBox in Opera 9.2x
            ilya_shaikovsky
            • 3. Re: Bug with suggestionBox in Opera 9.2x
              manoz

              It's been a while since I reported this problem. In the mean time I found some sort of a workaround, it's not exactly a solution, but a pretty messy javascript fix. If anyone's interested I could post it here, but I couldn't recommend it for production environments.

              • 4. Re: Bug with suggestionBox in Opera 9.2x
                eunnini

                pleazzzzz, post it manoz!

                I'd appreciate this so much!"

                • 5. Re: Bug with suggestionBox in Opera 9.2x
                  manoz

                  Ok, you've been warned :)

                  So, in opera, when you click a button the form doesn't get submitted;
                  To override this add onclick behavior to the submit button:

                  <h:commandButton id="button1" value="OK" action="..." onclick="this.form.submit()" />
                  


                  ... but there is a problem.

                  The form get's submitted and you have a post request but without the information of which button is clicked.
                  To override this you have to manually add an input which name and value pair is equal to that of a submit button.

                  So a complete solution is:
                  <h:commandButton id="button1" value="OK" action="..." onclick="richFacesOperaHack(this.form, 'button1', 'OK')" />
                  


                  and that javascipt function is:
                  ...
                  function richFacesOperaHack(form, commitButtonID, commitButtonValue) {
                   if (BrowserDetect.browser == "Opera") {
                   var node = document.getElementById("javax.faces.ViewState").cloneNode(false);
                   node.name = commitButtonID;
                   node.id = "randomlyGeneratedId"
                   node.value = commitButtonValue;
                   form.appendChild(node);
                   form.submit();
                   }
                   return true;
                  }
                  ...
                  


                  I clone the hidden input that jsf always generates instead of creating a completely new element.
                  BrowserDetect is a free javascript that I got from www.quirksmode.org

                  ...

                  Try it and give me some feedback on how it works for you.

                  • 6. Re: Bug with suggestionBox in Opera 9.2x
                    eunnini

                    Thank you so much - it really works!