Javascript does not work under JSF template again

时光怂恿深爱的人放手 提交于 2020-01-07 07:37:10

问题


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.

来源:https://stackoverflow.com/questions/15991653/javascript-does-not-work-under-jsf-template-again

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!