填写所需字段时,面验证不会丢失CSS样式
我想在以下问题上得到一些帮助,现在我非常感谢大家的帮助和关注 我在JSF2/Primefaces 5.1中有一个表单,其中一个组件更新选择中的另一个组件,这两个组件都是必需的 我的问题发生在验证之后,是在我填充其中一个字段之后,当这种情况发生时,组件自动填充另一个字段,但是验证样式在第二个组件中继续 请参阅SS,以便更好地理解: 提交前: 停止所需字段 填写字段并重新提交: 我如何才能改变这种行为并使样式保持在第二个字段中,我已经尝试了许多方法,但我没有主意,除了验证css之外,其他一切都可以完美工作 我的代码:填写所需字段时,面验证不会丢失CSS样式,css,jsf,jsf-2,primefaces,Css,Jsf,Jsf 2,Primefaces,我想在以下问题上得到一些帮助,现在我非常感谢大家的帮助和关注 我在JSF2/Primefaces 5.1中有一个表单,其中一个组件更新选择中的另一个组件,这两个组件都是必需的 我的问题发生在验证之后,是在我填充其中一个字段之后,当这种情况发生时,组件自动填充另一个字段,但是验证样式在第二个组件中继续 请参阅SS,以便更好地理解: 提交前: 停止所需字段 填写字段并重新提交: 我如何才能改变这种行为并使样式保持在第二个字段中,我已经尝试了许多方法,但我没有主意,除了验证css之外,其他一切都
<h:form id="stepInsertFormId" acceptcharset="UTF-8">
<p:panelGrid id="stepInsertPanelId" styleClass="formPanelGridPage" cellpadding="7" >
<p:row>
<p:column styleClass="adrGridLabel">
<p:outputLabel for="stageCodeInsertSelectId"
value="#{myMsg['common.stage']}"
title="#{myMsg['common.stage.title']}"
styleClass="myGridLabel" />
</p:column>
<p:column styleClass="adrGridInput" style="vertical-align: bottom;">
<p:selectOneMenu id="stageCodeInsertSelectId"
value="#{Step.stepInsert.selectedStage}"
var="stage"
converter="basedEntityConverter"
label="#{myMsg['common.stageCode.title']}"
filter="true"
required="true"
filterMatchMode="startsWith" >
<f:selectItem itemLabel="#{myMsg['common.select']}" itemValue="" />
<f:selectItems value="#{Step.stages}"
var="stageInsert"
itemLabel="#{stageInsert.id.stageCode}"
itemValue="#{stageInsert}" />
<p:column>
<h:outputText value="#{stage.id.stageCode}" />
</p:column>
<p:column>
<h:outputText value="#{stage.description}" />
</p:column>
<p:ajax event="change" process="@this"
update="stepInsertPanelId, :myMessagesId"
listener="#{Step.doReloadStepsInsert}" />
</p:selectOneMenu>
<p:spacer width="5px" height="1px"/>
<p:selectOneMenu id="stageDescriptionInsertSelectId"
value="#{Step.stepInsert.selectedStage}"
var="stage"
converter="basedEntityConverter"
filter="true"
required="true"
filterMatchMode="startsWith"
style="width:260px"
label="#{myMsg['common.stageDescription.title']}">
<f:selectItem itemLabel="#{myMsg['common.select']}" itemValue="" />
<f:selectItems value="#{Step.stages}"
var="stageInsert"
itemLabel="#{stageInsert.description}"
itemValue="#{stageInsert}" />
<p:column>
<h:outputText value="#{stage.id.stageCode}" />
</p:column>
<p:column>
<h:outputText value="#{stage.description}" />
</p:column>
<p:ajax event="change" process="@this"
update="stepInsertPanelId"
listener="#{Step.doReloadStepsInsert}" />
</p:selectOneMenu>
</p:column>
问题与更新阶段的生命周期有关,ajax升级第二个字段时,它会丢失ID的引用,此行为已经提供,并且有一个标记resetValuePrimefaces来解决此行为: 这是最终解决方案:
<p:ajax event="change" process="@this"
update="stageCodeInsertLabelId, stageCodeInsertSelectId
, stageDescriptionInsertSelectId
, :myMessagesId"
resetValues="true"
listener="#{Step.doReloadStepsInsert}" />
默认值为false
这篇文章帮助我理解并解决了这个问题
第三个屏幕截图是通过
h:form
按钮提交还是通过ajax提交?选择选项process=“@this stageDescriptionInsertSelected”
时,您可以尝试在处理第一个菜单值的同时处理第二个菜单值。第三个是在ajax提交之后。是我在第一个字段中选择一个项目的时候了,这个字段使用ajax填充第二个字段。我尝试了这个解决方案,但没有成功。我已经尝试更新de ID字段和表单您是否检查了右侧“相关”标题下的帖子(如果您在普通pc上查看此帖子)?不客气…因此您的问题实际上是重复的?