问题描述
p:tabView
组件存在严重问题.我已经将dynamic="true"
和cache="false"
设置为tabView.选项卡之一具有一些设置为required="true"
的输入组件.
现在,当我每次更改选项卡时,都会进行表单验证,并且FacesMessages将显示在咆哮声中.
以下是标签:
<ui:composition 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:p="http://primefaces.org/ui"
template="/WEB-INF/templates/globalTemplate.xhtml">
<ui:define name="title">#{adbBundle['home']}</ui:define>
<ui:define name="content">
<p:growl id="growl" showDetail="true" autoUpdate="true" />
<p:tabView id="adminTabView" dynamic="true" cache="false">
<p:tab title="#{adbBundle['admin.customerTab.title']}"
id="customerTab">
<ui:include src="/WEB-INF/includes/adminCustomer.xhtml" />
</p:tab>
<p:tab title="#{adbBundle['admin.activityTab.title']}"
id="activityTab">
<ui:include src="/WEB-INF/includes/addActivity.xhtml" />
</p:tab>
</p:tabView>
</ui:define>
</ui:composition>
adminCustomer.xhtml包含以下形式:
<ui:composition 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:p="http://primefaces.org/ui">
<h:form id="customerForm">
<p:panel id="addCustomerPanel" toggleable="true"
header="#{adbBundle['admin.addCustomerPanel.header.new']}">
<p:panelGrid columns="2" id="addCustomerTable"
styleClass="addCustomerTable">
<f:facet name="header">
<p:outputLabel id="header"
value="#{adbBundle['admin.addCustomerPanel.addCustomerTable.header']}" />
</f:facet>
<p:outputLabel for="customerName"
value="#{adbBundle['admin.addCustomerPanel.addCustomerTable.customerName']}" />
<h:panelGroup layout="block">
<p:inputText id="customerName" styleClass="customerName"
autocomplete="off"
label="#{adbBundle['admin.addCustomerPanel.addCustomerTable.customerName']}"
value="#{adminController.customerDTO.customerName}"
required="true" />
</h:panelGroup>
<p:outputLabel for="customerId"
value="#{adbBundle['admin.addCustomerPanel.addCustomerTable.customerId']}" />
<h:panelGroup layout="block">
<p:inputText id="customerId" autocomplete="off"
label="#{adbBundle['admin.addCustomerPanel.addCustomerTable.customerId']}"
value="#{adminController.customerDTO.customerId}" required="true">
<f:validator validatorId="customerIDValidator" />
</p:inputText>
</h:panelGroup>
<p:outputLabel for="activeStatus"
value="#{adbBundle['admin.addCustomerPanel.addCustomerTable.activeStatus']}" />
<h:panelGroup layout="block">
<p:selectBooleanCheckbox id="activeStatus"
value="#{adminController.customerDTO.active}" />
</h:panelGroup>
<f:facet name="footer">
<p:commandButton value="#{adbBundle['saveButton']}"
actionListener="#{adminController.saveCustomer}"
icon="ui-icon-check"
update=":growl, @form" />
</f:facet>
</p:panelGrid>
</p:panel>
</h:form>
</ui:composition>
我无法找到自己在做什么以及如何解决.我正在将Primefaces 3.4.2与JSF Mojarra 2.1.7-jbossorg一起使用.任何指针对我都会非常有帮助.
我也在PrimeFaces论坛中也问过这个问题.
这是tabView
的工作方式.以下是PrimeFaces跟踪器的相关问题:
- http://code.google.com/p/primefaces/issues/detail?id = 3423 .
- http://code.google.com/p/primefaces/issues/detail?id = 4143
如您所见,第一个标记为WontFix. 第二个是重复的,但最后您将看到另一个解决方法.
如果您仔细阅读该线程,可能会注意到某些解决方法仍然存在.如果您被迫使用tabView
,请尝试其中之一.如果要在不同选项卡中使用输入,还可以考虑使用 PrimeFaces-向导. /p>
I am having a serious issue with the p:tabView
component. I have set dynamic="true"
and cache="false"
to the tabView. One of the tabs has some input components which are set required="true"
.
Now when I am changing the tab each time, the form validation is occurring and the FacesMessages are being displayed in growl.
Here is the tab:
<ui:composition 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:p="http://primefaces.org/ui"
template="/WEB-INF/templates/globalTemplate.xhtml">
<ui:define name="title">#{adbBundle['home']}</ui:define>
<ui:define name="content">
<p:growl id="growl" showDetail="true" autoUpdate="true" />
<p:tabView id="adminTabView" dynamic="true" cache="false">
<p:tab title="#{adbBundle['admin.customerTab.title']}"
id="customerTab">
<ui:include src="/WEB-INF/includes/adminCustomer.xhtml" />
</p:tab>
<p:tab title="#{adbBundle['admin.activityTab.title']}"
id="activityTab">
<ui:include src="/WEB-INF/includes/addActivity.xhtml" />
</p:tab>
</p:tabView>
</ui:define>
</ui:composition>
The adminCustomer.xhtml contains the form and which is:
<ui:composition 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:p="http://primefaces.org/ui">
<h:form id="customerForm">
<p:panel id="addCustomerPanel" toggleable="true"
header="#{adbBundle['admin.addCustomerPanel.header.new']}">
<p:panelGrid columns="2" id="addCustomerTable"
styleClass="addCustomerTable">
<f:facet name="header">
<p:outputLabel id="header"
value="#{adbBundle['admin.addCustomerPanel.addCustomerTable.header']}" />
</f:facet>
<p:outputLabel for="customerName"
value="#{adbBundle['admin.addCustomerPanel.addCustomerTable.customerName']}" />
<h:panelGroup layout="block">
<p:inputText id="customerName" styleClass="customerName"
autocomplete="off"
label="#{adbBundle['admin.addCustomerPanel.addCustomerTable.customerName']}"
value="#{adminController.customerDTO.customerName}"
required="true" />
</h:panelGroup>
<p:outputLabel for="customerId"
value="#{adbBundle['admin.addCustomerPanel.addCustomerTable.customerId']}" />
<h:panelGroup layout="block">
<p:inputText id="customerId" autocomplete="off"
label="#{adbBundle['admin.addCustomerPanel.addCustomerTable.customerId']}"
value="#{adminController.customerDTO.customerId}" required="true">
<f:validator validatorId="customerIDValidator" />
</p:inputText>
</h:panelGroup>
<p:outputLabel for="activeStatus"
value="#{adbBundle['admin.addCustomerPanel.addCustomerTable.activeStatus']}" />
<h:panelGroup layout="block">
<p:selectBooleanCheckbox id="activeStatus"
value="#{adminController.customerDTO.active}" />
</h:panelGroup>
<f:facet name="footer">
<p:commandButton value="#{adbBundle['saveButton']}"
actionListener="#{adminController.saveCustomer}"
icon="ui-icon-check"
update=":growl, @form" />
</f:facet>
</p:panelGrid>
</p:panel>
</h:form>
</ui:composition>
I am unable to find what I am doing wrong and how to resolve it.I am using Primefaces 3.4.2 with JSF Mojarra 2.1.7-jbossorg. Any pointer would be very helpful to me.
I have asked this question in PrimeFaces forum too.
This is how tabView
works. Here are the relevant issues from the PrimeFaces tracker:
- http://code.google.com/p/primefaces/issues/detail?id=3423.
- http://code.google.com/p/primefaces/issues/detail?id=4143
As you can see the first one is marked as WontFix. The second is a duplicate but at the end you will see another workaround.
If you read that thread carefully you may notice that some workarounds still exists. Try one of them if you are forced to use tabView
. Also consider using PrimeFaces - Wizard if you want to use inputs in different tabs.
这篇关于Primefaces tabView在选项卡更改时执行表单验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!