【发布时间】:2019-11-02 14:09:36
【问题描述】:
我们正在实现文本框禁用或启用 jsf 输入组件的功能,具体取决于另一个输入组件(单选按钮)的值。该功能有效,但弹出警告框并显示错误
malformedXML: During update: new:j_idt335 not found
当我点击收音机选择选项时
单选按钮男 O 单选按钮女 O
输入框文本字段 男 [_____] 女 [____]
选择男性单选按钮后,女性输入框被禁用
选择女性单选按钮后,男性输入框被禁用
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
xmlns:c="http://java.sun.com/jsp/jstl/core"
template="/src/template.xhtml">
<ui:define name="content">
<h:form id="new" enctype="multipart/form-data">
<h:panelGroup id="id2">
<p:growl id="growl" sticky="true" showDetail="true" />
<p:wizard id="newWizard" showNavBar="true" widgetVar="wiz" flowListener="#{SelectMB.handleFlow}">
<p:tab id="tab"
title="Form">
<ui:include src="/jsf/formgender.xhtml" />
</p:tab>
</p:wizard>
</h:panelGroup>
</h:form>
</ui:define>
formgender.xhtml
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:pe="http://primefaces.org/ui/extensions"
>
<p:panel id="type" styleClass="panelNoBorder">
<p:fieldset toggleable="true" toggleSpeed="500"
legend="Info">
<div class="ui-g">
<div class="ui-g-1"><p:outputLabel value="genderType" /></div>
<div class="ui-g-3">
<p:row>
<h:selectOneRadio value="#{SelectMB.genderType}">
<f:selectItem itemValue="male"
itemLabel="male" />
<f:selectItem itemValue="female"
itemLabel="female" />
<f:ajax render="male" />
<f:ajax render="female" />
</h:selectOneRadio>
</p:row>
</div>
<div class="ui-g-1"><p:outputLabel value="male" /></div>
<div class="ui-g-3">
<p:row>
<p:inputText id="male" value="#{SelectMB.male}"
disabled="#{SelectMB.genderType eq 'female'}" />
</p:row>
</div>
</div>
<div class="ui-g">
<div class="ui-g-1"><p:outputLabel value="female" /></div>
<div class="ui-g-3">
<p:row>
<p:inputText id="female" value="#
{SelectMB.femaleList}" disabled="#{SelectMB.genderType eq 'male'}"
/>
</p:row>
</div>
</div>
</p:fieldset>
</p:panel>
SelectMB.java
private String genderType;
public String getgenderType() {
return genderType;
}
public void setgenderType(String genderType) {
this.genderType = genderType;
}
private String male;
private String femaleList;
public String getMale() {
return male;
}
public void setMale(String male) {
this.male = male;
}
public String getFemaleList() {
return femaleList;
}
public void setFemaleList(String femaleList) {
this.femaleList = femaleList;
}
该功能按预期工作。
错误信息:-
当我单击单选选项时,功能按预期工作,但警告框中会显示一条错误消息。
malformedXML: During update: new:j_idt335 not found
预期结果:-
如果选择了“一个”单选按钮,则应禁用另一个选项的文本输入字段。
最小的可重现示例。 jsf.2.0版
template.xhtml
<h:form id="new" enctype="multipart/form-data">
<ui:include src="/jsf/formgender.xhtml" /> </h:form>
formgender.xhtml
<h:selectOneRadio value="#{SelectMB.genderType}">
<f:selectItem itemValue="male" itemLabel="male" />
<f:selectItem itemValue="female" itemLabel="female" />
<f:ajax render="male" /> <f:ajax render="female" />
</h:selectOneRadio>
<p:inputText id="male" value="#{SelectMB.male}" disabled="#{SelectMB.genderType eq 'female'}" />
<p:inputText id="female" value="#{SelectMB.femaleList}" disabled="#{SelectMB.genderType eq 'male'}" />
【问题讨论】:
-
请将其设为minimal reproducible example。另请参阅stackoverflow.com/tags/jsf/info] 并提供版本信息
-
这是一个最小的可重现示例。 jsf.version 2.0 template.xhtml 跨度>
-
formgender.xhtml
-
请通过问题下方的编辑按钮编辑问题:stackoverflow.com/posts/56674386/edit
-
拜托,这不是minimal reproducible example。请参阅我在第一条评论中发布的第二个链接。关于模板的一些东西。而且它在很多方面都不是minimal reproducible example。