switchType="server" 如何在 <rich:tabPanel> 内使用多个表单?

How to use multiple forms inside <rich:tabPanel> with switchType="server"?

我们从 RichFaces 3 切换到 4,<rich:tabPanel> 存在一些概念性问题...使用 RichFaces 3 你可以做类似的事情:

<rich:tabPanel switchType="server">
    <rich:tab header="A">
        <h:form>
            <h:commandButton value="A1" />
        </h:form>
        <h:form>
            <h:commandButton value="A2" />
        </h:form>
    </rich:tab>
    <rich:tab header="B">
        <h:form>
            <h:commandButton value="B" />
        </h:form>
    </rich:tab>
    <rich:tab header="C">
        <h:form>
            <h:commandButton value="C" />
        </h:form>
    </rich:tab>
</rich:tabPanel>

这不再适用于 JSF 2 和 RichFaces 4 – 因为 <rich:tabPanel> 需要它自己的 <h:form> 对于 switchType="server""ajax"...只有客户端没有形式。所以我们现在必须像这样构建它:

<h:form>
    <rich:tabPanel switchType="server">
        <rich:tab header="A">
            <h:commandButton value="A1" />
            <h:commandButton value="A2" />
        </rich:tab>
        <rich:tab header="B">
            <h:commandButton value="B" />
        </rich:tab>
        <rich:tab header="C">
            <h:commandButton value="C" />
        </rich:tab>
    </rich:tabPanel>
</form>

行得通...但我无法再区分 A1A2,它们以前是单独的形式。

我们如何在不使用 switchType="client" 的情况下解决该问题?

您可以使用@execute 限制<a4j:commandButton execute="@region"> 的范围。可能最简单的方法是将数据包装在 <a4j:region> 中并在按钮上设置 execute="@region"

rich:tabPanel 工单中的多表单支持最近刚刚被拒绝,建议使用 a4j:region:

This will not be implemented, <a4j:region> can be used to limit the scope of execution inside a tab.

https://issues.jboss.org/browse/RF-11306