【发布时间】:2014-11-27 06:12:04
【问题描述】:
当我使用带有 dynamic="true" 的 p:tabView 时遇到问题,并且在一个选项卡上有一个 h:selectOneMenu,而在另一个选项卡上是一个 commandLink,它是 ajax="false"。单击 commandLink 两次后,selectOneMenu 的值会丢失。
tabView为dynamic="false"时不会出现此问题。
h:inputText 的值没有丢失,但我在日志文件中看到以下警告:
org.apache.myfaces.shared.renderkit.html.HtmlRendererUtils decodeUIInput WARNING: There should always be a submitted value for an input if it is rendered, its form issubmitted, and it was not originally rendered disabled or read-only. You cannot submit a form after disabling an input element via javascript. Consider setting read-only to true instead or resetting the disabled value back to false prior to form submission. Component : {Component-Path : [Class: javax.faces.component.UIViewRoot,ViewId: /form/regional/region.xhtml][Class: javax.faces.component.html.HtmlBody,Id: j_id_5][Class: javax.faces.component.html.HtmlForm,Id: TestForm][Class: org.primefaces.component.tabview.TabView,Id: tabviewTest][Class: org.primefaces.component.tabview.Tab,Id: j_id_8][Class: javax.faces.component.html.HtmlInputText,Id: j_id_f]}
这是表格:
<p:tabView dynamic="true" cache="true" id="tabviewTest">
<p:tab title="Tab 1">
<h:selectOneMenu value="#{Region.dropDownValue}" id="dropDown">
<f:selectItem itemLabel="" itemValue=""/>
<f:selectItem itemLabel="1" itemValue="1"/>
<f:selectItem itemLabel="2" itemValue="2"/>
<f:selectItem itemLabel="3" itemValue="3"/>
<f:selectItem itemLabel="4" itemValue="4"/>
</h:selectOneMenu>
<h:inputText value="#{Region.inputValue}" />
</p:tab>
<p:tab title="Tab 2">
<p:commandLink ajax="false"
id="link"
value="Test"
actionListener="#{Region.someActionMethod}" />
</p:tab>
</p:tabView>
这里是 Bean:
public class Region {
private Integer dropDownValue = 3;
private String inputValue = "Test";
public void someActionMethod(ActionEvent ev) {
System.out.println("someActionMethod called");
}
public Integer getDropDownValue() {
return dropDownValue;
}
public void setDropDownValue(Integer dropDownValue) {
this.dropDownValue = dropDownValue;
}
public String getInputValue() {
return inputValue;
}
public void setInputValue(String inputValue) {
this.inputValue = inputValue;
}
}
我的环境:Primefaces 5.0/5.1.RC1、Myfaces 2.1/2.2、Tomact 7
有什么想法可能是错的吗?
【问题讨论】:
-
“价值丢失”是什么意思?您的意思是该值已重置为默认值?还是空白?
-
看,
cache="true"和dynamic="true"在 IMO 上有些矛盾。设置cache="true"再试一次 -
对不起,我的意思是设置
cache="false" -
它不适用于
cache="false"- 我已经尝试过了。 -
你已经有了答案。为什么你不能有
dynamic="false"?
标签: jsf jsf-2 primefaces myfaces