0

I have found the thread answered by BalusC

It describes the exact problem I have. When I found it I thought I have found my answer as well, but for me the solution is not working. I had problems with the < h:outputScript> tag already, maybe it is the same problem (the < script> tag is working).

I have the same project description as the user Plaha, that put the question. I am trying to call a JavaScript function defined in the template page with the parameters attributes of the backing JSF bean. But for now the alert function is enough.

I`ve tried to make the page gridTest.xhtml to look like content.xhtml from the example, but it doesn't work.

The gridsTemplate.xhtml looks exactly like the template in the thread + I have the < head> tag in which I have some JavaScript functions. My gridTest.xhtml:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core">

<h:head>
<link rel="stylesheet" type="text/css"
    href="/juritest/resources/css/style.css" />
<script type="text/javascript"
    src="/juritest/resources/js/jquery-1.8.2.js"></script>
<script type="text/javascript" src="/juritest/resources/js/menu.js"></script>
</h:head>

<body>
<ui:composition template="../../templates/gridsTemplate.xhtml">
    <ui:define name="content">
        <h:form rendered="#{gridPopUpBean.testNotStarted}">
            ...
        </h:form>
        <h:form rendered="#{not gridPopUpBean.testNotStarted}">
            <h:outputScript target="body">
                alert("working?");
            </h:outputScript>
  ...

I have tried for curiosity to put the < h:outputScript directly under the ui:define like in the example, but it doesn't work either.

Community
  • 1
  • 1
CyberGriZzly
  • 379
  • 3
  • 9
  • 22
  • I`ve resolved it by putting a < script> tag after the ui:defined and it worked. – CyberGriZzly Apr 13 '13 at 20:33
  • The answer was already in the 1st sentence of the question you found: *"Everything outside `` is **ignored** during building the view."* – BalusC Apr 13 '13 at 20:36
  • possible duplicate of [Javascript does not work under JSF template](http://stackoverflow.com/questions/11027285/javascript-does-not-work-under-jsf-template) – BalusC Apr 13 '13 at 20:36
  • I saw that sentence. I've put the < script> tag after the composition tag. A question that I wonder is: you said that "All with all, your entire content.xhtml must look like this:" and put the "includes" in the composition tag. Why? No HTML tag, no HEAD tag... – CyberGriZzly Apr 14 '13 at 10:41
  • Because it's a template client. The html/head are already in the master template as referenced in ``. As said, any content outside `` is ignored. See also the link in the "See also" section the answer you found: http://stackoverflow.com/questions/4792862/how-to-include-another-xhtml-in-xhtml-using-jsf-2-0-facelets – BalusC Apr 14 '13 at 10:51

0 Answers0