我在 WebSphere Application Server 8 上使用 Primefaces 3.2 和 Apache Myfaces 2。
我有一个表单,您可以通过更改 selectOneButton 来选择 2 个不同的视图。
当我在没有 ajax 行为的情况下使用此按钮(使用命令按钮提交)时,值更改工作正常。
但是当我使用这样的东西时:
<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>
然后当我更改按钮并使用 ajax 更新表单时 bean.val 的值为空。(setter 方法中的记录器打印 2 次空值)。
为什么值为空?