2012-07-13 27 views
2

我的WebSphere Application Server 8JSF selectOneButton使用Ajax更新失去了價值

我有一個表格,您可以通過更改selectOneButton選擇2個不同的視圖上使用Primefaces 3.2與Apache MyFaces的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> 

然後bean.val的值是空的,當我改變按鈕和更新與阿賈克斯的形式。 (記錄器在setter方法中打印2次空值)。

爲什麼值爲空?

+0

你的'bean'的作用域是否至少有'ViewScope'或更多? – Gaim 2012-07-13 07:29:05

+0

是的,我的Bean是ViewScoped。 – veote 2012-07-13 08:02:53

回答

0

每當你有這樣的行爲,意味着一些更新沒有正確指定。嘗試總體使用update =「@form」。 爲此目的使用SelectOneButton有點不常見,您可以使用TabView來實現此目的。

+0

我嘗試過 - 但沒有改變。它只有1個渲染與否,所以我想我可以用selectOneButton做到這一點 – veote 2012-07-13 08:04:37