0 Replies Latest reply on May 6, 2015 6:40 AM by Mehmet Salgar

    gatein-resources.xml and the timeline the javascripts called

    Mehmet Salgar Novice

      Hi everybody,


      I have a problem with GateIn and Javascripts.


      I am working on an application that is using Portletbridge for JSF and a JSF framework, this JSF framework is dependent on jQuery and specially self calling functions with jQuery.


      The problem is this mechanism not working correctly under GateIn Portal while JSF application can't place it <script> elements under the <head> section of the HTML document.


      So what I try to do is to define explicitly necessary Javascripts inside of the gatein-resources.xml and technically it is working but now I am getting a timing problem.


      Below how the JSF framework create html elements.


      <button id="textEntryPageForm:wordcount_refresh_action" name="textEntryPageForm:wordcount_refresh_action" class="" onclick="PrimeFaces.ab({s:&quot;textEntryPageForm:wordcount_refresh_action&quot;,u:&quot;textEntryPageForm:list_results_rcv_pf_table&quot;});return false;" type="submit">

           <span class="ui-button-text ui-c">ui-button</span>


          <script id="textEntryPageForm:wordcount_refresh_action_s"           type="text/javascript">PrimeFaces.cw("CommandButton","widget_textEntryPageForm_wordcount_refresh_action",   {id:"textEntryPageForm:wordcount_refresh_action",widgetVar:"widget_textEntryPageForm_wordcount_refresh_action"});</script>



      As you can see html elements created from JSF framework depends on Javascripts objects 'PrimeFaces.ab', 'PrimeFaces.cw', for these objects to be created this self calling functions must be called (and actually they are in the head part of the html document). The problem is the javascripts included in the gatein-resources.xml are not called during the DOM tree creation of the HTML page but oncomplete of the page. So when DOM tree is created the function calls to 'PrimeFaces.ab', 'PrimeFaces.cw' occurs but the initialization of these objects occurs when the creation of the DOM tree completed, so too late.


      So my question how I can influence that the initialization of these scripts occurs before the creation of DOM elements, basically before the oncomplete event of the browser?


      Thx for the answers.