Javascript无法使用JSF [英] Javascript not working with JSF
问题描述
我正在开发一个jsf页面,我正在尝试通过javascript编写一个按钮onclick事件,以便能够在jsf dataTable中动态添加行;但问题是jsf不再加载javascript代码
我试图使用外部js文件
I'm working on a jsf page and I'm trying to program a button onclick event by javascript to be able to add rows dynamically in a jsf dataTable ; but the problem is that jsf is not loading javascript code anymore I tried to use an external js file
<h:outputScript name="">
并尝试使用标签
有什么建议吗?谢谢!
and also tried using the tag Any suggestions please ? Thanks!
推荐答案
您可以使用JSF < h:outputScript>
或html < script>
tag。
You can use either JSF <h:outputScript>
or html <script>
tag.
首先,您需要在WebContent下创建一个文件夹并命名它作为资源。在资源文件夹下,您可以创建要放置资源的文件夹,例如CSS,javascript,图像等。
First, you need to create a folder under WebContent and name it as resources. Under resources folder, you can create folders where you want to put your resources such as CSS, javascript, images etc.
对于JSF < h :outputScript>
:
<h:outputScript library="script" name="/script.js"</h:outputScript>
其中库的值是包含javascript文件的文件夹的名称。
Where the value of the library is the name of the folder which contains your javascript file.
以下是HTML的代码< script>
:
Here's the code for HTML <script>
:
<script src="#{request.contextPath}/resources/script/script.js"></script>
这篇关于Javascript无法使用JSF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!