2 Replies Latest reply on Jun 27, 2008 12:50 PM by marinew

    SuggestionBox JS error during updateChoices (RF 3.1.5)

    marinew

      Hi,

      I have a strange problem with suggestionBox, RichFaces 3.1.5 and Firefox 2.
      I've got a page A containing a suggestionBox. If I come from page B to page A, suggestionBox on page A works correctly. If I come from page C to page A, suggestionBox don't work !

      Suggestion action method is correctly called and return a list of data.
      But on client side, a4j:status don't stop and popup result isn'y displayed.
      I get the following JavaScript error :

      $ is not defined
      
      (?)("richfaces_suggestionEntry", div#body:formActesOperatoires:tableActes:rechCodeSuggest.dr-sb-common-container)a4j_3_1_4.GAorg.a... (line 4153)
      updateChoices(undefined)suggestionbox.js (line 604)
      onComplete(Object _query=Object _documentElement=html options=Object, Object)suggestionbox.js (line 733)
      bind()a4j_3_1_4.GAorg.a... (line 210)
      after processing updates" ); window.setTimeout()
      



      wich point to JS file a4j_3_1_4.GAorg.ajax4jsf.javascript.PrototypeScript on line 4153 :

      ]4122/*--------------------------------------------------------------------------*/
      4123
      4124if (!document.getElementsByClassName) document.getElementsByClassName = function(instanceMethods){
      4125 function iter(name) {
      4126 return name.blank() ? null : "[contains(concat(' ', @class, ' '), ' " + name + " ')]";
      4127 }
      4128
      4129 instanceMethods.getElementsByClassName = Prototype.BrowserFeatures.XPath ?
      4130 function(element, className) {
      4131 className = className.toString().strip();
      4132 var cond = /\s/.test(className) ? $w(className).map(iter).join('') : iter(className);
      4133 return cond ? document._getElementsByXPath('.//*' + cond, element) : [];
      4134 } : function(element, className) {
      4135 className = className.toString().strip();
      4136 var elements = [], classNames = (/\s/.test(className) ? $w(className) : null);
      4137 if (!classNames && !className) return elements;
      4138
      4139 var nodes = $(element).getElementsByTagName('*');
      4140 className = ' ' + className + ' ';
      4141
      4142 for (var i = 0, child, cn; child = nodes; i++) {
       4143 if (child.className && (cn = ' ' + child.className + ' ') && (cn.include(className) ||
       4144 (classNames && classNames.all(function(name) {
       4145 return !name.toString().blank() && cn.include(' ' + name + ' ');
       4146 }))))
       4147 elements.push(Element.extend(child));
       4148 }
       4149 return elements;
       4150 };
       4151
       4152 return function(className, parentElement) {
       4153 return $(parentElement || document.body).getElementsByClassName(className); <========== Problem here
       4154 };
       4155}(Element.Methods);
       4156
       4157/*--------------------------------------------------------------------------*/
      


      In A4g log, when I type a character in suggestionBox, I have :
      debug[18:41:44,718]: set timeout for request suggestion
      debug[18:41:44,734]: Observer event occurs
      debug[18:41:44,734]: Call data for update choices
      debug[18:41:44,734]: Have Event [object Object] with properties: target: [object HTMLInputElement], srcElement: undefined, type: keydown
      debug[18:41:44,734]: NEW AJAX REQUEST !!! with form :body:formActesOperatoires
      debug[18:41:44,734]: Append text control body:formActesOperatoires:tableActes:rechCode with value [tt] and value attribute []
      debug[18:41:44,734]: Append hidden control body:formActesOperatoires:tableActes:rechCodeSuggest_selection with value [] and value attribute [null]
      debug[18:41:44,734]: Append hidden control body:formActesOperatoires_SUBMIT with value [1] and value attribute [1]
      debug[18:41:44,734]: Append hidden control autoScroll with value [] and value attribute [null]
      debug[18:41:44,734]: Append hidden control javax.faces.ViewState with value [8EgC7hvJoXWgMHaUZxk5rx66APlnNueyP32ajDxbvc/i5akMf2jX5WWSSrgXZJhYKXq0epYyMus6yIYKdwr0uOheIjdsKfp03QYDic7/mAIYaFPjvIjow2OLV06wFNI0] and value attribute [8EgC7hvJoXWgMHaUZxk5rx66APlnNueyP32ajDxbvc/i5akMf2jX5WWSSrgXZJhYKXq0epYyMus6yIYKdwr0uOheIjdsKfp03QYDic7/mAIYaFPjvIjow2OLV06wFNI0]
      debug[18:41:44,734]: parameter body:formActesOperatoires:tableActes:rechCodeSuggest with value body:formActesOperatoires:tableActes:rechCodeSuggest
      debug[18:41:44,734]: parameter inputvalue with value tt
      debug[18:41:44,750]: Start XmlHttpRequest
      debug[18:41:44,750]: Reqest state : 1
      debug[18:41:44,750]: QueryString: AJAXREQUEST=(...)
      debug[18:41:44,750]: Reqest state : 1
      debug[18:41:44,906]: Reqest state : 2
      debug[18:41:44,906]: Reqest state : 3
      debug[18:41:44,906]: Reqest state : 3
      debug[18:41:44,906]: Reqest state : 4
      debug[18:41:44,906]: Reqest end with state 4
      debug[18:41:44,906]: Response with content-type: text/xml;charset=UTF-8
      debug[18:41:44,906]: Full response content: <?xml version="1.0"?> (...) </body></html>
      debug[18:41:44,906]: Header Ajax-Expired not found, search in <meta>
      debug[18:41:44,906]: search for elements by name 'meta' in element #document
      debug[18:41:44,906]: getElementsByTagName found 2
      debug[18:41:44,906]: Find <meta name='Ajax-Update-Ids' content='body:divBarreEtat,body:divBarreEtatModalPanelCodeCcam,body:formActesOperatoires:tableActes:rechCodeSuggest:suggest'>
      debug[18:41:44,906]: Find <meta name='Ajax-Response' content='true'>
      debug[18:41:44,906]: Header Ajax-Update-Ids not found, search in <meta>
      debug[18:41:44,906]: search for elements by name 'meta' in element #document
      debug[18:41:44,921]: getElementsByTagName found 2
      debug[18:41:44,921]: Find <meta name='Ajax-Update-Ids' content='body:divBarreEtat,body:divBarreEtatModalPanelCodeCcam,body:formActesOperatoires:tableActes:rechCodeSuggest:suggest'>
      debug[18:41:44,921]: Update page by list of rendered areas from response body:divBarreEtat,body:divBarreEtatModalPanelCodeCcam,body:formActesOperatoires:tableActes:rechCodeSuggest:suggest
      debug[18:41:44,921]: search for elements by name 'script' in element #document
      debug[18:41:44,921]: getElementsByTagName found 11
      debug[18:41:44,921]: <script> in response with src=/gcm-web-patients/faces/a4j_3_1_4.GAorg.ajax4jsf.javascript.AjaxScript
      debug[18:41:44,921]: Such element exist in document
      debug[18:41:44,921]: <script> in response with src=/gcm-web-patients/faces/a4j_3_1_4.GAorg.ajax4jsf.javascript.PrototypeScript
      debug[18:41:44,921]: Such element exist in document
      debug[18:41:44,921]: <script> in response with src=/gcm-web-patients/faces/a4j_3_1_4.GAorg/richfaces/renderkit/html/scripts/utils.js
      debug[18:41:44,921]: Such element exist in document
      debug[18:41:44,921]: <script> in response with src=/gcm-web-patients/faces/a4j_3_1_4.GAorg/richfaces/renderkit/html/scripts/browser_info.js
      debug[18:41:44,921]: Such element exist in document
      debug[18:41:44,937]: <script> in response with src=/gcm-web-patients/faces/a4j_3_1_4.GAorg/richfaces/renderkit/html/scripts/modalPanel.js
      debug[18:41:44,937]: Such element exist in document
      debug[18:41:44,937]: <script> in response with src=/gcm-web-patients/faces/a4j_3_1_4.GAorg/richfaces/renderkit/html/scripts/modalPanelBorders.js
      debug[18:41:44,937]: Such element exist in document
      debug[18:41:44,937]: <script> in response with src=/gcm-web-patients/faces/a4j_3_1_4.GAorg/ajax4jsf/javascript/scripts/form.js
      debug[18:41:44,937]: Such element exist in document
      debug[18:41:44,937]: <script> in response with src=/gcm-web-patients/faces/a4j_3_1_4.GAorg.ajax4jsf.javascript.SmartPositionScript
      debug[18:41:44,937]: Such element exist in document
      debug[18:41:44,937]: <script> in response with src=/gcm-web-patients/faces/a4j_3_1_4.GAorg/richfaces/renderkit/html/scripts/scriptaculo.js
      debug[18:41:44,937]: Such element exist in document
      debug[18:41:44,937]: <script> in response with src=/gcm-web-patients/faces/a4j_3_1_4.GAorg/richfaces/renderkit/html/scripts/suggestionbox.js
      debug[18:41:44,937]: Such element exist in document
      debug[18:41:44,937]: search for elements by name 'link' in element #document
      debug[18:41:44,937]: getElementsByTagName found 6
      debug[18:41:44,937]: <link> in response with src=/gcm-web-patients/faces/a4j_3_1_4.GAorg/richfaces/renderkit/html/css/modalPanel.xcss/DATB/eAFjlbr0AAAC6gHS
      debug[18:41:44,937]: Such element exist in document
      debug[18:41:44,937]: <link> in response with src=/gcm-web-patients/faces/a4j_3_1_4.GAcss/panel.xcss/DATB/eAFjlbr0AAAC6gHS
      debug[18:41:44,937]: Such element exist in document
      debug[18:41:44,937]: <link> in response with src=/gcm-web-patients/faces/a4j_3_1_4.GAcss/table.xcss/DATB/eAFjlbr0AAAC6gHS
      debug[18:41:44,953]: Such element exist in document
      debug[18:41:44,953]: <link> in response with src=/gcm-web-patients/faces/a4j_3_1_4.GAorg/richfaces/renderkit/html/css/suggestionbox.xcss/DATB/eAFjlbr0AAAC6gHS
      debug[18:41:44,953]: Such element exist in document
      debug[18:41:44,953]: <link> in response with src=/gcm-web-patients/css/general.css
      debug[18:41:44,953]: Such element exist in document
      debug[18:41:44,953]: <link> in response with src=/gcm-web-patients/css/skinSansNav.css
      debug[18:41:44,953]: Such element exist in document
      debug[18:41:44,953]: Attempt to update part of page for Id: body:divBarreEtat
      debug[18:41:44,953]: call getElementById for id= body:divBarreEtat
      debug[18:41:44,953]: Replace content of node by replaceChild()
      debug[18:41:44,953]: search for elements by name 'script' in element div
      debug[18:41:44,953]: getElementsByTagName found 0
      debug[18:41:44,953]: Scripts in updated part count : 0
      debug[18:41:44,953]: Update part of page for Id: body:divBarreEtat successful
      debug[18:41:44,953]: Attempt to update part of page for Id: body:divBarreEtatModalPanelCodeCcam
      debug[18:41:44,953]: call getElementById for id= body:divBarreEtatModalPanelCodeCcam
      debug[18:41:44,953]: Replace content of node by replaceChild()
      debug[18:41:44,953]: search for elements by name 'script' in element div
      debug[18:41:44,968]: getElementsByTagName found 0
      debug[18:41:44,968]: Scripts in updated part count : 0
      debug[18:41:44,968]: Update part of page for Id: body:divBarreEtatModalPanelCodeCcam successful
      debug[18:41:44,968]: Attempt to update part of page for Id: body:formActesOperatoires:tableActes:rechCodeSuggest:suggest
      debug[18:41:44,968]: call getElementById for id= body:formActesOperatoires:tableActes:rechCodeSuggest:suggest
      debug[18:41:44,968]: Replace content of node by replaceChild()
      debug[18:41:44,968]: search for elements by name 'script' in element table
      debug[18:41:44,984]: getElementsByTagName found 0
      debug[18:41:44,984]: Scripts in updated part count : 0
      debug[18:41:44,984]: Update part of page for Id: body:formActesOperatoires:tableActes:rechCodeSuggest:suggest successful
      debug[18:41:44,984]: call getElementById for id= ajax-view-state
      debug[18:41:44,984]: Hidden JSF state fields: [object HTMLSpanElement]
      debug[18:41:44,984]: Namespace for hidden view-state input fields is undefined
      debug[18:41:44,984]: search for elements by name 'input' in element span
      debug[18:41:44,984]: getElementsByTagName found 1
      debug[18:41:44,984]: Replace value for inputs: 24 by new values: 1
      debug[18:41:44,984]: Input in response: javax.faces.ViewState
      debug[18:41:44,984]: Found same input on page with type: hidden
      debug[18:41:44,984]: Found same input on page with type: hidden
      debug[18:41:44,984]: Found same input on page with type: hidden
      debug[18:41:44,984]: search for elements by name 'INPUT' in element span
      debug[18:41:45,000]: getElementsByTagName found 0
      debug[18:41:45,000]: Replace value for inputs: 24 by new values: 0
      debug[18:41:45,000]: call getElementById for id= _A4J.AJAX.focus
      debug[18:41:45,000]: No focus information in response
      debug[18:41:45,000]: call getElementById for id= org.ajax4jsf.oncomplete
      debug[18:41:45,000]: Call component oncomplete function after processing updates
      debug[18:41:45,031]: call getElementById for id= _ajax:data
      debug[18:41:45,031]: AJAX response complete - updateChoices
      



      And here is source code of component (inside the footer facet of a dataTable) :
      <h:inputText id="rechCode" size="30"
       binding="#{devisActeOperatoireForm.uiSaisieRechercheCode}"
       title="#{msgR.DevisActeOperatoire_InstructionsRechercheCode}"/>
      
      <rich:suggestionbox id="rechCodeSuggest" for="rechCode"
       width="500" height="150" minChars="0"
       binding="#{devisActeOperatoireForm.uiSuggestCode}"
       suggestionAction="#{devisActeOperatoireController.suggererCodesCcam}"
       var="elt">
       <h:column>
       <h:outputText value="#{elt.code}" />
       </h:column>
       <h:column>
       <h:outputText value="#{elt.libelle}" />
       </h:column>
      
       <%-- Les proprietes reRender et oncomplete sont mises a jour par le controller --%>
       <a4j:support event="onselect" ajaxSingle="true"
       actionListener="#{devisActeOperatoireController.selectionnerOuCreerCodeCcamEvent}"/>
      </rich:suggestionbox>
      



      Any idea, please ?
      Is it a bug or bad usage ?
      Thanks
      Marine