在selectOneMenu中,当验证对f:validator,f:attribute失败时,没有调用valueChangeListener,我试着立即=" true"但也没有成功。 任何帮助将受到高度赞赏。谢谢。 以下是代码段:
<p:selectOneMenu id="firstinputselectone" rendered="#{!dynamicUIPreEnrollmentAction.singleProfile}"
valueChangeListener="#{dynamicUIPreEnrollmentAction.showLayoutPreview}"
styleClass="#{extraFieldDTO.isReadOnly eq '1' ?'disabledInputFieldSelectItem' :'enabledInputFieldSelectItem'}"
disabled="#{extraFieldDTO.isReadOnly eq '1'}"
value="#{extraFieldDTO.stringFieldValue}">
<f:selectItem itemLabel="#{msg.DROP_SELECTONE}"
id="selectItem_24" />
<f:selectItems
value="#{dropDownParserAction.getGenericLinkedKeyValueListMap(null,extraFieldDTO.dropDownSearchValue,extraFieldDTO.dropDownType,extraFieldDTO.firstLinkedDropDownType)}"
id="selectItems_24655" />
<p:ajax event="change" id="ajax_2" update="@form" />
<f:validator validatorId="dynamicUIValidator" />
<f:attribute name="DYNAMICUIDATAOBJECT" value="#{extraFieldDTO}" />
</p:selectOneMenu>
</h:panelGroup>
</p:fieldset>
<p:spacer width="50" />
<p:fieldset legend="#{msg.LBL_BACKCARD}" toggleable="false"
style="width:400px;height:400px;background-color:#e6e6e6">
<h:panelGroup>
<br clear="none" />
<br clear="none" />
<br clear="none" />
<br clear="none" />
<p:spacer height="40" />
<h:graphicImage id="layout_present_idar590" rendered="#{dynamicUIPreEnrollmentAction.backProfileLayout ne null}"
value="data:image/jpg;base64,#{dynamicUIPreEnrollmentAction.backProfileLayout}" />
</h:panelGroup>
</p:fieldset>
</h:panelGrid>
</div>
</p:outputPanel>
答案 0 :(得分:0)
Thanks, I got the workaround for this by using rendered="!facesContext.validationFailed" in the layouts panel which was not supposed to be rendered when validation fails.
Here is the code snippet:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:p="http://primefaces.org/ui">
<p:tabView
rendered="#{extraFieldDTO.fieldType.equals('IDENTITY_CREDENTIAL')}">
<p:tab title="#{msg.LBL_IDENTITY_CREDENTIAL}">
<br clear="none" />
<br clear="none" />
<p:outputPanel autoUpdate="true">
<h:panelGroup
rendered="#{extraFieldDTO.fieldType.equals('IDENTITY_CREDENTIAL')}">
<h:panelGrid columns="2" style="width:100%;"
columnClasses="padding widthDyna,row1-padding">
<h:panelGroup id="panelGroup_31D0">
<p:outputLabel value="#{extraFieldDTO.displayText}" />
<h:outputText id="idar563" styleClass="red" value="*" rendered="#{extraFieldDTO.isRequiredField eq '1'}" />
<p:selectOneMenu id="firstinputselectone" rendered="#{!dynamicUIPreEnrollmentAction.singleProfile}" immediate="true"
valueChangeListener="#{dynamicUIPreEnrollmentAction.showLayoutPreview}"
styleClass="#{extraFieldDTO.isReadOnly eq '1' ?'disabledInputFieldSelectItem' :'enabledInputFieldSelectItem'}"
disabled="#{extraFieldDTO.isReadOnly eq '1'}"
value="#{extraFieldDTO.stringFieldValue}">
<f:selectItem itemLabel="#{msg.DROP_SELECTONE}"
id="selectItem_24" />
<f:selectItems
value="#{dropDownParserAction.getGenericLinkedKeyValueListMap(null,extraFieldDTO.dropDownSearchValue,extraFieldDTO.dropDownType,extraFieldDTO.firstLinkedDropDownType)}"
id="selectItems_24655" />
<p:ajax event="change" id="ajax_2" update="@form" immediate="true"/>
<f:validator validatorId="dynamicUIValidator" />
<f:attribute name="DYNAMICUIDATAOBJECT" value="#{extraFieldDTO}" />
</p:selectOneMenu>
<p:selectOneMenu id="firstinputselectone_SingleProfile"
rendered="#{dynamicUIPreEnrollmentAction.singleProfile}"
valueChangeListener="#{dynamicUIPreEnrollmentAction.showLayoutPreview}"
styleClass="#{extraFieldDTO.isReadOnly eq '1' ?'disabledInputFieldSelectItem' :'enabledInputFieldSelectItem'}"
disabled="#{extraFieldDTO.isReadOnly eq '1'}"
value="#{extraFieldDTO.stringFieldValue}">
<f:selectItems
value="#{dropDownParserAction.getGenericLinkedKeyValueListMap(null,extraFieldDTO.dropDownSearchValue,extraFieldDTO.dropDownType,extraFieldDTO.firstLinkedDropDownType)}"
id="selectItems_24655_SingleProfile" />
<f:validator validatorId="dynamicUIValidator" />
<f:attribute name="DYNAMICUIDATAOBJECT" value="#{extraFieldDTO}" />
</p:selectOneMenu>
</h:panelGroup>
<h:panelGroup style="width:40%">
<h:outputText
value="#{msg.HELP_DYNA_FORM_EDIT_FIELDMGMT_HELP}: "
rendered="#{extraFieldDTO.helpText !=null}" />
<h:outputText value="#{extraFieldDTO.displayText}"
rendered="#{extraFieldDTO.helpText !=null}" />
<br clear="none" />
<span class="garyText"> <h:outputText
value="#{extraFieldDTO.helpText}"
rendered="#{extraFieldDTO.helpText !=null}" /></span>
<br clear="none" />
</h:panelGroup>
</h:panelGrid>
<br clear="none" />
<p:message for="firstinputselectone" id="message_38" />
<br clear="none" />
<p:outputPanel autoUpdate="true" id="layout_Panel" rendered="#{not empty extraFieldDTO.stringFieldValue and !facesContext.validationFailed}">
<div align="center">
<h:panelGrid id="layout_present" columns="3"
rendered="#{(not empty extraFieldDTO.stringFieldValue) and ((dynamicUIPreEnrollmentAction.frontProfileLayout ne null) or (dynamicUIPreEnrollmentAction.backProfileLayout ne null))}">
<p:fieldset legend="#{msg.LBL_FRONTCARD}" toggleable="false"
style="width:400px;height:400px;background-color:#e6e6e6">
<h:panelGroup>
<br clear="none" />
<p:spacer height="30" />
<h:graphicImage id="layout_present_idar589" rendered="#{dynamicUIPreEnrollmentAction.frontProfileLayout ne null}"
value="data:image/jpg;base64,#{dynamicUIPreEnrollmentAction.frontProfileLayout}" />
</h:panelGroup>
</p:fieldset>
<p:spacer width="50" />
<p:fieldset legend="#{msg.LBL_BACKCARD}" toggleable="false"
style="width:400px;height:400px;background-color:#e6e6e6">
<h:panelGroup>
<br clear="none" />
<br clear="none" />
<br clear="none" />
<br clear="none" />
<p:spacer height="40" />
<h:graphicImage id="layout_present_idar590" rendered="#{dynamicUIPreEnrollmentAction.backProfileLayout ne null}"
value="data:image/jpg;base64,#{dynamicUIPreEnrollmentAction.backProfileLayout}" />
</h:panelGroup>
</p:fieldset>
</h:panelGrid>
</div>
</p:outputPanel>
</h:panelGroup>
</p:outputPanel>
</p:tab>
</p:tabView>
</ui:composition>