0

I got a MainPage.xhtml which includes a lot of other xhtmls like:

<ui:include src="/pages/includes/included1.xhtml"
                    id="included1ID"/>
<ui:include src="/pages/includes/included2.xhtml"
                    id="included2ID"/>

... and so on.

There is some logic behind it which included page will be loaded, works fine. I want to write some Javascript in the included pages which runs immediately as the page loads (for example in the included1.xthml).

I tried adding this section right after the <ui:composition> tag:

<h:head>
    <h:outputScript>
          .
          .
        some JS
          .
          .
    </h:outputScript>
</h:head>

It works fine if I use it in a NOT included page, but doesn't work on included ones. Is there any way to add my JS to those pages?

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
K.Gabor
  • 89
  • 2
  • 11
  • Possible duplicate of [How to add different javascripts on a page when using ui:composition](https://stackoverflow.com/questions/9000101/how-to-add-different-javascripts-on-a-page-when-using-uicomposition) – Kukeltje Sep 04 '18 at 11:53
  • It's definitely not a duplicate. I have no problem adding any JS to my ui:composition but to another included page. – K.Gabor Sep 06 '18 at 10:08
  • It for 100% sure IS a duplicate... you cannot add a head in a composite and have it used in another page. See the duplicate – Kukeltje Sep 06 '18 at 10:25
  • So basically it is not possible what I want to do, right? – K.Gabor Sep 11 '18 at 08:50
  • What you want to achieve is possible how you try to do it is not. Please read the duplicate correctly... put the script tag inside the composition add a `target="head"` to it and don't wrap it in an `h:head` – Kukeltje Sep 11 '18 at 08:52

0 Answers0