我的每个选项卡都有一个数据表、一个输入和一个添加按钮。当我单击添加按钮时,验证发生在打开和关闭的选项卡上。我在打开的选项卡中看到了关闭选项卡的错误。有没有办法让验证只发生在打开的选项卡中。
<p:accordionPanel id="pnl_accord_codetables" dynamic="true" cache="false">
<p:ajax event="tabChange" listener="#{pc_Maintenence.onTabChange}" immediate="true"/>
<c:forEach items="#{pc_Maintenence.codeMaintenenceTables}" var="codetable">
<p:tab title="#{codetable.tableName}">
<util:datatable_util dataTableTemplate="#{codetable}"
dataTableList="#{pc_Maintenence.getDataTableList(codetable.tableList_managedBeanName.concat('.').concat(codetable.tableList_propertyName))}"
dataTableListItem="#{pc_Maintenence.getDataTableListItem(codetable.tableList_rowItemClassName, codetable)}"
actionMethodsBean="#{pc_Maintenence}"
buildMessagePanel="true"/>
</p:tab>
</c:forEach>
</p:accordionPanel>
此代码在复合材料内
<p:panel id="pnl_add" rendered="#{cc.attrs.dataTableTemplate.addRow}">
<ui:repeat value="#{cc.attrs.dataTableTemplate.columns}" var="column">
<p:outputLabel styleClass="outputLabel" value="#{column.heading}"
for="inputtext" rendered="#{column.inputForAddingRecord}"/>
<p:inputText value="#{(cc.attrs.dataTableListItem)[column.name]}"
rendered="#{column.inputForAddingRecord}" id="inputtext"
required="#{not empty param[cc.add.clientId] and column.required}"
validator="#{column.validate}"/>
<div class="clear"> </div>
</ui:repeat>
</p:panel>
<p:panel id="pnl_commandbuttons">
<p:commandButton styleCl2ass="commandButton"
rendered="#{cc.attrs.dataTableTemplate.addRow}"
binding="#{cc.add}"
action="#{cc.attrs.actionMethodsBean.addRowAction(cc.attrs.dataTableTemplate)}"
value="Add"
update="pnl_datatable pnl_add pnl_msg @parent"
title="Add">
<p:collector value="#{cc.attrs.dataTableListItem}" addTo="#{cc.attrs.dataTableList}" />
</p:commandButton>
<p:commandButton styleClass="commandButton"
rendered="#{cc.attrs.dataTableTemplate.addRow or cc.attrs.dataTableTemplate.editable}"
action="#{cc.attrs.actionMethodsBean.submitAction(cc.attrs.dataTableTemplate)}"
value="Submit"
update="pnl_datatable pnl_add pnl_msg @parent"
title="Submit">
</p:commandButton>
</p:panel>
这是我的列类中的验证方法
public void validate(FacesContext context, UIComponent component, Object value) throws ValidatorException {
ResourceBundle resource = (ResourceBundle)getManagedBean("regex");
String pattern = resource.getString(this.regexName);
if(pattern != null){
RegexValidator regexValidator = new RegexValidator();
regexValidator.setPattern(pattern);
regexValidator.validate(context, component, value);
}
}