richfaces a4j:支持意外调用后端方法的事件



我使用Richfaces 3.3开发JSF 1.2应用程序。我有一个弹出窗口,其中包含一个rich:extendedDataTable。当我单击表中的一行时,我想启用或禁用一个按钮,并使用a4j:support event="onRowClick"

这里有一些代码:

<h:form>
    <rich:panel id="main">
        <a4j:commandButton id="completed" value="Completed" 
        rendered="#{bean.completedCase}" />
        <a4j:commandButton  value="Open"
                oncomplete="#{rich:component('popupId')}.show(...)">
        </a4j:commandButton>
        <rich:modalPanel id="popupId">
            <a4j:region>
                <rich:extendedDataTable id="source" value="#{bean.sourceItems}" 
                    var="sourceItem" selectionMode="single" >
                    <a4j:support event="onRowClick" eventsQueue="pickQueue" reRender="copy" >
                        <f:setPropertyActionListener value="#{sourceItem}"
                            target="#{bean.sourceSelection}" />
                    </a4j:support>
                    ....
                </rich:extendedDataTable>           
                <a4j:commandButton id="copy" value="Copy" />
            </a4j:region>
            <a4j:commandButton value="Ok" reRender="completed"
                    oncomplete="#{rich:component('popupId')}.hide();return false;">
            </a4j:commandButton>
        </rich:modalPanel>
    </rich:panel>
</h:form>

问题是,当我单击一行时,在后端会调用一些用于呈现按钮的方法:rendered="#{bean.completedCase}",但按钮不在弹出窗口上,而是在弹出窗口之外的页面上。知道为什么除了用于表的方法之外还有其他方法吗?

尝试在a4j:support标签上使用ajaxsingle="true"。由于当onrowclick触发请求时您正在使用h:form,所以在更新模型阶段,h:form中的所有组件都将在服务器上进行处理。

希望这能有所帮助。

不建议嵌套<h:form> s,但我们可以有多个<h:form> s,请尝试修改代码,使<h:commandButton>在一个h:form中,而<h:modalPanel>在另一种形式的中

希望这能有所帮助。u也可以尝试使用<a4j:form>进行modalPanel

最新更新