在 SelectOnemenu 上重置 JSF Primefaces 输入值
Posted
技术标签:
【中文标题】在 SelectOnemenu 上重置 JSF Primefaces 输入值【英文标题】:JSF Primefaces input values reset upon SelectOnemenu 【发布时间】:2021-03-03 10:03:37 【问题描述】:在手动选择 selectOneMenu id="format" 的值时重置输入的输入值
selectOneMenu id="format" 的渲染效果很好。但是在选择 selectOneMenu id="format" 的下拉值时,输入的字段输入值是空白的。
页面
Employee name[Mark] Employee Type [New]
Format [Select some drop down value]
.
电流输出
Employee name[Entered Value Disappeared/null] Employee Type [Selected value disappeared/null]
Format [Selected some drop down value]
预期输出
Employee name[Mark] Employee Type [New]
Format [Selected Value]
.
我已经尝试添加
<p:ajax event="valueChange" immediate="true" process="@form" />
The rendering fails if I add it for the selectOneMenu
我有下面的代码
main.xhtml
<h:form id="newFormBank" enctype="multipart/form-data">
<h:panelGroup id="id">
<p:growl id="growl" sticky="true" showDetail="true" />
<p:wizard id="newBankWizard" showNavBar="true" widgetVar="bankWiz" flowListener="#javaMB.wizardFlow">
<p:tab id="pro" title="Banks">
<ui:include src="/jsf/xyz.xhtml" />
<ui:include src="/jsf/employeeloan.xhtml" />
</p:tab>
</p:wizard>
</h:panelGroup>
</h:form>
employeeeloan.xhtml
<p:panel id="employeeLoan" styleClass="panelNoBorder">
<div class="ui-g"> <div class="ui-g-1"><p:outputLabel value="Employee Name" /></div>
<div class="ui-g-3"> <p:row> <p:inputText id="employeeName" maxlength="50" style="width: 65%;" value="#javaMB.visaDetailsEntity.employeeName" > </p:inputText> </p:row> </div>
<div class="ui-g-1"><p:outputLabel value="Employee Type" /></div>
<div class="ui-g-3">
<p:row> <p:selectOneMenu id="employeeTypeList" value="#javaMB.visaDetailsEntity.employeeTypeCode" >
<f:selectItem itemLabel="Select Release Type" itemValue=""> </f:selectItem>
<f:selectItem itemLabel="New" itemValue="1" />
<f:selectItem itemLabel="Existing" itemValue="2" /> </p:selectOneMenu> </p:row> </div> </div>
<div class="ui-g"> <div class="ui-g-1"><p:outputLabel value="CREDIT" /></div>
<div class="ui-g-3">
<p:row>
<p:selectOneMenu id="format" value="javaMB.visaDetailsEntity.visaType.visaId">
<f:selectItem itemLabel="VISA" itemValue="1" />
<f:selectItem itemLabel="MASTER CARD" itemValue="2" />
<f:selectItem itemLabel="DISCOVER" itemValue="3" />
<f:selectItem itemLabel="AMERICAN EXPRESS" itemValue="4" />
<f:ajax render="@form" />
</p:selectOneMenu>
</p:row>
</div>
</div>
<div class="ui-g">
<div class="ui-g-1"><p:outputLabel value="VISA" rendered="#javaMB.visaDetailsEntity.visaType.visaId == '1'"/></div>
<div class="ui-g-3"> <p:row>
<p:inputText id="visaeg" maxlength="9" size="30" value="#javaMB.visaDetailsEntity.malaustin" label="VISA1" rendered="#javaMB.visaDetailsEntity.visaType.visaId == '1'">
</p:inputText>
</p:row>
</div>
<div class="ui-g-1"><p:outputLabel value="VISA" rendered="#javaMB.visaDetailsEntity.visaType.visaId == '1'"/></div>
<div class="ui-g-3">
<p:row>
<p:inputText id="visaegg" maxlength="11" size="30" value="#javaMB.visaDetailsEntity.malecinyc" label="VISA2" onchange="negateLongitude()" rendered="#javaMB.visaDetailsEntity.visaType.visaId == '1'">
</p:inputText>
</p:row>
</div>
</div>
<div class="ui-g">
<div class="ui-g-1"><h:outputLabel value="MASTER CARD" style="overflow: hidden" rendered="#javaMB.visaDetailsEntity.visaType.visaId == '3'"/></div>
<div class="ui-g-3">
<p:row>
<p:inputText id="masterd" maxlength="7" size="30" value="#javaMB.visaDetailsEntity.atepmo" rendered="#javaMB.visaDetailsEntity.visaType.visaId == '3'">
</p:inputText>
</p:row>
</div>
<div class="ui-g-1"><h:outputLabel for="masterdt" value="MASTER CARD DETAILS" rendered="#javaMB.visaDetailsEntity.visaType.visaId == '3'"/></div>
<div class="ui-g-3">
<p:row>
<p:inputText id="datilsmast" maxlength="8" size="30" value="#javaMB.visaDetailsEntity.atepllanyc" rendered="#javaMB.visaDetailsEntity.visaType.visaId == '3'">
</p:inputText>
</p:row>
</div>
</div>
<div class="ui-g">
<div class="ui-g-1"><h:outputLabel value="DISCOVER" rendered="#javaMB.visaDetailsEntity.visaType.visaId == '4'"/></div>
<div class="ui-g-3">
<p:row>
<p:inputText id="ltdiscover" maxlength="2" size="30" value="#javaMB.visaDetailsEntity.egrssfo" rendered="#javaMB.visaDetailsEntity.visaType.visaId == '4'">
</p:inputText>
</p:row>
</div>
<div class="ui-g-1"><h:outputLabel value="DISCOVER Details" rendered="#javaMB.visaDetailsEntity.visaType.visaId == '4'"/></div>
<div class="ui-g-3">
<p:row>
<p:inputText id="lodiscover" maxlength="4" size="30" value="#javaMB.visaDetailsEntity.eongtx" rendered="#javaMB.visaDetailsEntity.visaType.visaId == '4'">
</p:inputText>
</p:row>
</div>
</div>
<div class="ui-g">
<div class="ui-g-1"><h:outputLabel value="AExp AZ" rendered="#javaMB.visaDetailsEntity.visaType.visaId == '2'"/></div>
<div class="ui-g-3">
<p:row>
<p:inputText id="azaexp" maxlength="2" size="30" value="#javaMB.visaDetailsEntity.aexpaz" rendered="#javaMB.visaDetailsEntity.visaType.visaId == '2'">
</p:inputText>
</p:row>
</div>
<div class="ui-g-1"><h:outputLabel value="AExp FL" rendered="#javaMB.visaDetailsEntity.visaType.visaId == '2'"/></div>
<div class="ui-g-3">
<p:row>
<p:inputText id="flaexp" maxlength="4" size="30" value="#fvLocationMB.coordinateForm.aexpazfl" rendered="#javaMB.visaDetailsEntity.visaType.visaId == '2'">
</p:inputText>
</p:row>
</div>
</div>
</div>
</p:fieldset>
</p:panel>
</ui:composition>
javaMB 吸气剂二传手 实体 吸气剂设置器
【问题讨论】:
【参考方案1】:你的 p:ajax 语句是错误的,它可能应该是这样的:
<p:ajax event="valueChange" update="@form" />
在这里找到内部工作原理的详尽解释:
Understanding PrimeFaces process/update and JSF f:ajax execute/render attributes
【讨论】:
以上是关于在 SelectOnemenu 上重置 JSF Primefaces 输入值的主要内容,如果未能解决你的问题,请参考以下文章
如何使用自定义 JSF 转换器将 h:selectOneMenu 项转换为 List<String>?
在 JSF 中向 selectOneMenu 添加“未选择”选项的最佳方法
JSF 2.0:对 selectOneMenu 使用枚举值 [重复]
如何在 JSF 标记 selectOneMenu 中使用转换器? [复制]
Primefaces valueChangeListener 或 <p:ajax 侦听器未触发 p:selectOneMenu [重复]