Ajax提交以更新jsf 1.2中的backing bean属性

时间:2013-05-13 14:21:08

标签: richfaces jsf-1.2

我正在使用带有富脸库的jsf 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>

如上面所示,我想使用按钮将带有ajax的h:inputText提交给服务器。 只应处理PART内部。

我的问题是我想使用ajax从someOtherBean.processData方法访问someBean.Data。我可以实现吗?

我尝试了以下事情,但没有成功。

1)使用4j:commandButton并使用ajaxSingle =“true”,因为只需要提交某些部分。(如果我提交整个 表格验证错误将被抛出)

2)使用h:commandButton with a4j:support

3)将必要的组件包含在内部,使用此组件仅将选定的区域提交给服务器。

在上述所有情况中,表单都已提交,但someBean.Data始终返回null。

1 个答案:

答案 0 :(得分:1)

如果Bean1是请求作用域,您可以使用

获取该bean的当前实例
Bean1 bean =(Bean1) FacesContext.getCurrentInstance().getExternalContext().getRequestMap().get("bean1");

如果bean是会话作用域,那么

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

您可以在processData方法

中编写上述代码

有关托管bean之间通信的详细信息,请访问this链接

相关问题