我有一个Primefaces项目,其中所有视图都是通过Netbeans生成的。 对某些视图进行了编辑,并使其成为常用的视图,以使其更加透明。我的问题是,CRUD的VIEW部分是常见的部分,因此它的引用方式如下:
myView / myListView.xhtml:
<p:dialog id="InvoiceViewDlg" widgetVar="InvoiceViewDialog" modal="true" resizable="false" appendTo="@(body)" header="#{bundle.ViewInvoiceTitle}">
<ui:include src="View.xhtml"/>
</p:dialog>
引用myView / View.xhtml:
<?xml version="1.0" encoding="UTF-8" ?>
<!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:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:components="http://xmlns.jcp.org/jsf/composite/Components"
xmlns:my="http://mywork.com/jsf/facelets">
<ui:composition>
<ui:include src="/view/form/formView.xhtml">
<ui:param name="item" value="#{invoiceController.selected}" />
<ui:param name="formType" value="invoice"/>
<ui:param name="controller" value="#{invoiceController}"/>
</ui:include>
</ui:composition>
</html>
引用/view/form/formView.xhtml,这就是问题所在:
<p:commandButton value="#{bundle.Close}" onclick="PF('FormViewDialog').hide()" styleClass="cancelButton"/>
在每个View表单上都引用了formView,不幸的是,由于onclick事件中的引用错误,关闭按钮(不起作用的X)不起作用。我不知道如何使它适用于每种形式...有人有什么想法吗?
编辑:
我将myView / View.xhtml编辑为:
<?xml version="1.0" encoding="UTF-8" ?>
<!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:ui="http://xmlns.jcp.org/jsf/facelets"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:components="http://xmlns.jcp.org/jsf/composite/Components"
xmlns:my="http://mywork.com/jsf/facelets">
<ui:composition>
<ui:include src="/view/form/formView.xhtml">
<ui:param name='dialogname' value='InvoiceViewDialog'/>
<ui:param name="item" value="#{invoiceController.selected}" />
<ui:param name="formType" value="invoice"/>
<ui:param name="controller" value="#{invoiceController}"/>
</ui:include>
</ui:composition>
</html>
还有我的/view/form/formView.xhtml:
<p:commandButton value="#{bundle.Close}" onclick="PF('#{dialogname}')).hide()" styleClass="cancelButton"/>
可悲的是,这是我仍然遇到的错误: