0
votes

I have a custom tag called "fieldWrapper" to bind labels with their respective inputs and provide validation messages.

The code of the component:

<h:panelGroup id="#{for}CompleteFieldContainer"
              styleClass="completeFieldContainer"
              layout="block"
              rendered="#{rendered}">
    <h:panelGroup id="#{for}FieldWithLabelContainer" layout="block"
                  styleClass="fieldWithLabelContainer #{fieldWrapperBean.getRequiredClass(required)} #{totalSizeClass}">
        <c:if test="#{!empty check and check}">
            <div class="labelContainer #{labelSizeClass} checkInput">
                <ui:insert />
            </div>
            <div class="labelContainer #{for}LabelContainer checkStyle">
                <h:outputLabel for="#{for}" value="#{label}" title="#{title}"/>
            </div>
        </c:if>            
        <c:if test="#{empty check or not check}">
            <div class="labelContainer #{labelSizeClass} #{for}LabelContainer #{checkStyle}">
                <h:outputLabel for="#{for}" value="#{label}" title="#{title}"/>
            </div>
            <ui:insert />
        </c:if>
    </h:panelGroup>
    <h:panelGroup rendered="#{renderError}" layout="block" styleClass="messageContainer">
        <p:message for="#{for}" id="#{for}Message" rendered="true"/>
    </h:panelGroup>
</h:panelGroup>

One example of this tag is the following:

<gitags:fieldWrapper for="codeInput"
                     label="#{msg.code}"
                     labelSizeClass="size75"
                     totalSizeClass="size175"
                     required="false">
        <p:inputText id="codeInput" 
                     value="#{clienteFinderManager.codigo}"
                     styleClass="inputText size100"/>
</gitags:fieldWrapper>

It automatically adds a message for that input, that is rendered when bean validation triggers.

It's working perfectly inside all components except p:tabView.

When I use it inside a tabView messages are queued but not written, but, if i add manually messages after the component they are written:

<gitags:fieldWrapper for="codeInput"
                     label="#{msg.code}"
                     labelSizeClass="size75"
                     totalSizeClass="size175"
                     required="false">
        <p:inputText id="codeInput" 
                     value="#{clienteFinderManager.codigo}"
                     styleClass="inputText size100"/>
        <p:message for="codeInput" id="codeInputMessage" rendered="true"/>
</gitags:fieldWrapper>

Bean Validation Inside Tabs

Any idea of why is this happening?

2

2 Answers

-1
votes

I have a fix in any primeface version. You need to take <p:outputLabel> instead of <p:message>. Take one string variable message and set error message in to that . Keep <p:ajax> inside<p: tabView> on tabChange event call the action method from bean and empty the error message. Because we need every time while changing the tab the error message should clear. After click on the submit button then only the error message will show. If any clarification contact me.