无法访问jsf组件中的javascript文件

发布于 2024-12-12 09:19:54 字数 1229 浏览 5 评论 0原文

我有一个必须访问 javascript 文件的 jsf 组件,我添加了这个输出脚本,如下面的代码所示,我在生成的 html 中收到错误,并且无法访问 javascript。 javascript 文件位于 document_root/js 目录中

我该如何解决这个问题,谢谢您的帮助。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:composite="http://java.sun.com/jsf/composite"
      xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:head><title>(For validation only)</title>
<link href="./css/styles.css" 
      rel="stylesheet" type="text/css"/> 
</h:head>
<h:body>
<composite:interface/>
<composite:implementation>
<h:outputScript library="js" name="messages.js" />
<h:outputScript library="js" name="DateValidation.js" />

<h:form id="f">
    <h:outputText value="Date" />
    <h:inputText id="dateA" 
        onblur="return validateDateField('f:dateA');">
    </h:inputText>
</h:form>   

</composite:implementation>

</h:body>
</html>

I have a jsf component that must access to a javascript file, i added this whith outputScript as in the code bellow, I get an error in the generated html, and the javascript can't be reached.
The javascript file is located in document_root/js directory

How can i resolve this problem, thank you for your help.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:composite="http://java.sun.com/jsf/composite"
      xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:head><title>(For validation only)</title>
<link href="./css/styles.css" 
      rel="stylesheet" type="text/css"/> 
</h:head>
<h:body>
<composite:interface/>
<composite:implementation>
<h:outputScript library="js" name="messages.js" />
<h:outputScript library="js" name="DateValidation.js" />

<h:form id="f">
    <h:outputText value="Date" />
    <h:inputText id="dateA" 
        onblur="return validateDateField('f:dateA');">
    </h:inputText>
</h:form>   

</composite:implementation>

</h:body>
</html>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

空心空情空意 2024-12-19 09:19:54

这些文件必须放置在 /resources 子文件夹中。因此,您应该在公共网页内容中包含以下内容:

  • /resources/js/DateValidation.js
  • /resources/js/messages.js

不相关对于具体问题,您的复合组件方法非常尴尬。我建议查看 https://stackoverflow.com/tags/composite-component/info

Those files have to be placed in the /resources subfolder. So, you should have the following in the public webcontent:

  • /resources/js/DateValidation.js
  • /resources/js/messages.js

Unrelated to the concrete problem, your composite component approach is pretty awkward. I'd suggest to check out tag wiki: https://stackoverflow.com/tags/composite-component/info

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文