Search code examples
jsfrichfacesseam

javascript inside xhtml (Richfaces)


i am trying to include jquery and jquery-ui libraries inside xhtml. Ive heard that richfaces already have jquery,but jquery-ui doesnt. I have no idea how to include them.

In addition to this, i have another js library that uses jquery and jquery-ui. So, what do i need to do to import these 3 js sources and use them inside a

<script type="text/javascript"> </script>

block? Where do these js files have to be located?

Thank you.


Solution

  • RichFaces 4.x comes indeed with jQuery bundled. It's available with the resource name jquery.js and is usually only auto-included when a certain RichFaces component requires it, but you can also explicitly include it by <h:outputScript>.

    As to your own JS files, just put them in the /resources folder of the public webcontent and use <h:outputScript> the usual way.

    Assuming

    WebContent
     |-- resources
     |    |-- jquery-ui.js
     |    `-- yourscript.js
     :
    

    here's how you could reference it (note that jquery.js is been supplied by RichFaces, not yourself!)

    <h:head>
        ...
        <h:outputScript name="jquery.js" />
        <h:outputScript name="jquery-ui.js" />
        <h:outputScript name="yourscript.js" />
    </h:head>