2013-05-13 52 views
0

我使用JSF 1.2具有豐富的臉庫阿賈克斯提交到JSF更新後臺bean屬性1.2

我有一個這樣的形式:

<a4j:form> 

    <!-- lof of other components here --> 
    <h:panelGrid> 

     <h:inputText id="someOrg" value="#{someBean.Data}"> 
     <a4j:commandButton id=""action="${someOtherBean.processData}" value="Submit"> <!-- it can be a4j:commandButton too--> 
    </h:panelGrid> 


    <!-- some components will be rendered based on above submission --> 

</a4j:form> 

如上表格所示,我要提交h:用ajax將inputText傳遞給使用按鈕的服務器。 只有PART內部應該被處理。

我的問題是我想從someOtherBean.processData方法訪問someBean.Data與ajax.How我可以實現嗎?

我嘗試了下面的東西,但沒有成功。

1)使用4J:命令按鈕和使用ajaxSingle = 「真」,因爲只有某些部分需要提交(如果我提交整個 表單驗證錯誤回報會被拋出)

2)使用H:。的commandButton與a4j:支持

3)將必要的組件內部,使用這將只提交選定的區域服務器。

在上述所有情況下,表單都被提交,但someBean.Data總是返回null。

+0

inputText組件未關閉。檢查一次。 – pudaykiran 2013-05-14 07:38:19

回答

1

如果Bean1是請求範圍,你可以使用獲取這個bean的當前實例

Bean1 bean =(Bean1) FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("bean1"); 

如果bean是會在你的processData方法隨後

Bean1 bean = (Bean1) FacesContext.getCurrentInstance().getExternalContext() 
      .getSessionMap().get("bean1"); 

你可以寫上面的代碼範圍的

有關託管bean之間的通信的更多信息,請通過this鏈接