Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to enforce loading of jQuery in RichFaces?

I'm using jQuery on my page. However, I do NOT use RichFaces tags on every page. Subsequently, jQuery is NOT injected by RF in every page. In order to avoid loading an additional jQuery library, how do I properly instruct RichFaces to load its jQuery own library?

This is an issue, because the RF-jQuery library overwrites my custom jQuery that I load. Also, the RF-jQuery libraries are always the last libraries to load, which is not good neither, because I need jquery-ui.js and jquery-migrate-1.2.1.min.js to load AFTER a jQuery library has been loaded.

<head>
    <!-- JS -->
    <span id="out">
        Richfaces-jQuery enforce with a4j:outputPanel
    </span>

    <script src="/ccms/resources/js/jquery-ui.js"></script>
    <script src="/ccms/resources/js/jquery-migrate-1.2.1.min.js"></script>

    <!-- The CK editor -->
    <script src="/ccms/resources/ckeditor_4_2_custom/ckeditor.js"></script>
    <script src="/ccms/resources/js/jquery.capty.min.js"></script>

    <!-- &lt;ui:debug hotkey=&quot;x&quot; /&gt; -->
    <script type="text/javascript" src="/ccms/javax.faces.resource/jsf.js.jsf?ln=javax.faces&amp;stage=Development"></script>
    <script type="text/javascript" src="/ccms/org.richfaces.resources/javax.faces.resource/org.richfaces.staticResource/4.3.3.Final/Packed/jquery.js"></script>
    <script type="text/javascript" src="/ccms/org.richfaces.resources/javax.faces.resource/org.richfaces.staticResource/4.3.3.Final/Packed/packed/packed.js"></script>
    <link type="text/css" rel="stylesheet" href="/ccms/org.richfaces.resources/javax.faces.resource/org.richfaces.staticResource/4.3.3.Final/Packed/DEFAULT/packed/packed.css" />
</head>
like image 582
feder Avatar asked Feb 16 '23 09:02

feder


1 Answers

RichFaces 4.x-bundled jQuery is available as follows:

<h:outputScript name="jquery.js" />

Yes, astonishingly without any library!

You only need to make sure that you use <h:head> instead of <head>. I also strongly recommend to load your own JS resources by <h:outputScript> as well.

like image 160
BalusC Avatar answered Feb 24 '23 09:02

BalusC