[英]JSF selectOneButton with ajax update lost value
I use Primefaces 3.2 with Apache Myfaces 2 on WebSphere Application Server 8. 我将Primefaces 3.2与WebSphere Application Server 8上的Apache Myfaces 2一起使用。
I have a form, where you can select 2 different view by changing a selectOneButton. 我有一个窗体,您可以通过更改selectOneButton来选择2个不同的视图。
When I use this button without ajax behavior (submit with command button) then the value change works fine. 当我使用此按钮而没有ajax行为时(使用命令按钮提交),则值更改正常。
But when I use something like this: 但是当我使用这样的东西:
<h:form id="form">
<p:panel header="Panel" toggleable="true" closable="true" id="pan1">
<p:panel header="Options" toggleable="true" collapsed="true" id="pan2">
<p:panelGrid style="width:100%; text-align:center;" id="pan3">
<p:row>
<!-- some outputLabels -->
<p:column rowspan="2" style="width:130px;">
<p:splitButton value="Show" action="#{ graph.update }"
update=":form" id="splitbtn">
<p:menuitem value="Update 2"
action="#{ graph.update2 }"
update=":form" />
</p:splitButton>
</p:column>
</p:row>
<p:row>
<p:column>
<p:selectOneButton id="btn1"
value="#{ bean.val }">
<f:selectItem itemLabel="lbl1" itemValue="1" />
<f:selectItem itemLabel="lbl2" itemValue="2" />
<p:ajax event="change"
update=":firstChartForm" />
</p:selectOneButton>
</p:column>
<!-- more coloumns -->
</p:row>
</p:panel>
<!-- more content -->
</p:panel>
</h:form>
Then the value of bean.val is empty when I change the button and update the form with ajax. 然后,当我更改按钮并使用ajax更新表单时,bean.val的值为空。 (Logger in setter method prints 2 times empty value).
(设置方法中的记录器将打印2倍的空值)。
Why is the value empty? 为什么值是空的?
It is a PrimeFaces selectOneButton Bug. 这是PrimeFaces selectOneButton错误。 Fixed with PrimeFaces 3.4
PrimeFaces 3.4修复
Link to Issue 3767 in Issue Tracker: 链接到问题跟踪器中的问题3767:
http://code.google.com/p/primefaces/issues/detail?id=3767 http://code.google.com/p/primefaces/issues/detail?id=3767
This was fixed in version 3.4 of PrimeFaces. 此问题已在PrimeFaces 3.4版中修复。
Every time that you have such a behavior, means that some updates don't specified correctly. 每当您有这种行为时,就意味着未正确指定某些更新。 try to use update="@form" overall.
尝试整体使用update =“ @ form”。 it is a little uncommon to use SelectOneButton for this purpose, you can use TabView alternatively to achieve this.
为此目的使用SelectOneButton有点少见,您也可以使用TabView来实现。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.