Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf 2 如何在facelet页面中包含外部javascript文件?_Jsf 2_Primefaces - Fatal编程技术网

Jsf 2 如何在facelet页面中包含外部javascript文件?

Jsf 2 如何在facelet页面中包含外部javascript文件?,jsf-2,primefaces,Jsf 2,Primefaces,在使用Facelet模板的Facelet页面中,如下所示: <h:head> <h:outputScript name="custom.js" library="javascript" target="head"/> </h:head> <ui:composition template="../../WEB-INF/Template.xhtml"> </ui:composition> 但是看看为我的按钮生成的HTML,我的自

在使用Facelet模板的Facelet页面中,如下所示:

<h:head>
    <h:outputScript name="custom.js" library="javascript" target="head"/>
</h:head>
<ui:composition template="../../WEB-INF/Template.xhtml">

</ui:composition>
但是看看为我的按钮生成的HTML,我的自定义javascript代码不包括在内,只添加了函数名

<button id="createupdateform:j_idt18" oncomplete:function(xhr, status, args){handleSaveNewMember(xhr, status, args);}});return false;" type="submit"><span class="ui-button-text">Save</span></button>

你可以把它放进你的
你好,丹尼尔,多亏了这个,你还能帮我解决问题吗?我已经更新了我的帖子。我的回答解决了你原来的问题吗?关于你的新问题,你不应该看到你的handleSaveNewMember代码附加到你的按钮中,没关系,它将在你的js文件中。。。在您所支持的按钮中,您可能需要单击ctrl+F5一次来刷新jsHi文件,以便只查看对您发布的函数名kust的引用。。对不起,我不确定我的问题是否真的得到了回答,因为我单击按钮时对话框没有关闭。什么都没有发生。我认为我的代码没有执行。对于start,编写一个简单的js方法closeDialog(){addMemberDlg.hide();}并从oncomplete=“closeDialog()”调用它,当然您需要将它放在js文件中……它甚至被调用了吗?closeDialog(){alert('hey')}看到警报了吗?
function handleSaveNewMember(xhr, status, args) {
    /*More Code*/
    addMemberDlg.hide();
}
<button id="createupdateform:j_idt18" oncomplete:function(xhr, status, args){handleSaveNewMember(xhr, status, args);}});return false;" type="submit"><span class="ui-button-text">Save</span></button>
<ui:composition template="../../WEB-INF/Template.xhtml">
    <ui:define name="content">
        <h:outputScript name="showmembers.js" library="javascript" target="head"/>
    </ui:define>
</ui:composition>
<ui:composition template="../../WEB-INF/Template.xhtml">
    <h:outputScript name="custom.js" library="javascript" target="head"/>
</ui:composition>