发生验证错误时,防止在p:tabview中切换选项卡

时间:2019-07-11 18:44:12

标签: primefaces

“在大约5个不同的页面上,我们具有带有多个<p:tab>的tabView。在所有选项卡上,我们都有一个必填字段(例如'value')。我们希望阻止它们在进行验证时切换选项卡错误(不能为空)。”

足迹1:

UI:

<p:tabView id="mainTabView" binding="#{configurationController.messagesTab}">
    <p:ajax event="tabChange" listener="# {configurationController.onTabChange()}" />
    <p:tab id="common" title="Eligibility">
        <ui:include src="configurationInclude.xhtml">
    </p:tab>
    <p:tab id="common" title="MISC">                    
        <ui:include src="configurationInclude.xhtml">
    </p:tab>
</p:tabView>

后备豆:

private TabView messagesTab = new TabView();
public void onTabChange(TabChangeEvent event) {
    TabView tabView = (TabView) event.getComponent();

    int activeIndex = tabView.getChildren()
        .indexOf(event.getTab());

    this.getMessagesTab()
        .setActiveIndex(activeIndex);
    }
public TabView getMessagesTab() {
    return messagesTab;
    }

    public void setMessagesTab(TabView messagesTab) {
    this.messagesTab = messagesTab;
    }

足迹2:

<p:tabView id="mainTabView" dynamic="true" cache="false">
    <p:tab id="common" title="Eligibility">
        <ui:include src="configurationInclude.xhtml">
    </p:tab>
    <p:tab id="common" title="MISC">                    
        <ui:include src="configurationInclude.xhtml">
    </p:tab>
</p:tabView>

0 个答案:

没有答案