【问题标题】:a4j:included rich:dataTable negatively affects a4j:commandButtona4j:included rich:dataTable 对 a4j:commandButton 产生负面影响
【发布时间】:2011-01-15 07:45:09
【问题描述】:

我有一个带有 index.jsp 的 JSF/RichFaces 设置,其中 a4j:includes 是另一段包含 rich:dataTable 的代码。

它最初呈现良好,然后在index.jsp 的下拉列表中选择一个项目并单击“检索”a4j:commandButton 使用支持 bean 的 setChosen 方法在后端进行投标。支持 bean 更新类成员,然后模型读取元素在单独的文件 content.jsp 中调用其 getter,该文件是 a4j:included。我更新的 tabPanel 出现了。

我可以在 Eclipse 控制台中看到输出。但是当我再次按下按钮时,什么也没有发生。 tomcat 6.0 日志中没有任何内容,控制台上也没有任何内容。

EDIT1 将问题缩小到我的content.jsp 文件而不是上面的index.jsp 代码,我发现rich:dataTable 元素是问题所在。当我从content.jsp 中删除这个元素时,我可以一遍又一遍地重新单击“检索”按钮,它会重新加载我的选项卡面板。我一放进去,第一次点击就ok了,然后按钮会点击,但是什么都没有发生,按钮也没有取消点击退出。

rich:dataTable 提供数据的方法不应该是可疑的,因为它至少在第一次工作,但它只执行一些xpath 例程并返回一个ArrayList<MyDataList>

鉴于编辑,现在有人可以建议如何使用rich:dataTable 以免造成任何麻烦吗?该元素位于 rich:tabPanel 内,而 h:form 内则仅此而已。

谢谢

EDIT2: 为了响应下面的评论请求,以下是完整的受影响代码列表,尽可能简短地重现该问题。 @Damo,请注意a4j:commandButtonrich:dataTable 位于不同的文件中,因为后者位于a4j:included 的jsp 文件中。 另请注意,<%@ taglib uri=... 引用已从两个文件中删除。

index.jsp:

<f:loadBundle basename="messages" var="msg" />

<f:view>
    <rich:page pageTitle="MyTitle" markupType="xhtml">
    <h:outputText id="setup" value="#{MyBacking.setup}" />
        <rich:toolBar height="35" itemSeparator="line">
            <rich:toolBarGroup location="left">
                <a4j:form>
                    <a4j:outputPanel id="panel">
                        <h:outputText style="text-align: center" value="Select " />
                        <h:selectOneMenu id="nodes" value="#{MyBacking.chosen}">
                            <f:selectItems value="#{MyBacking.nodes}" />
                        </h:selectOneMenu>
                        <a4j:commandButton value="Retrieve"
                            reRender="panel,contentPanel,currNode,lastOp"
                            onclick="this.disabled=true" oncomplete="this.disabled=false" />
                    </a4j:outputPanel>
                </a4j:form>
            </rich:toolBarGroup>
        </rich:toolBar>

        <rich:panel>
            <h:panelGroup layout="block" id="contentPanel">
                <a4j:include viewId="#{MyBacking.viewId}">
                    <f:param name="targetIdParam" value="content" />
                </a4j:include>
            </h:panelGroup>
        </rich:panel>
    </rich:page>
</f:view>

a4j:includedcontent.jsp:

<h:form id="myConfig">
    <rich:tabPanel switchType="client" rendered="true">
        <rich:tab styleClass="tab" label="Connections">
            <rich:dataTable onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
                onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
                cellpadding="0" cellspacing="0" width="100%" border="0" var="item"
                value="#{MyBacking.DataList}">
                <rich:column style="text-align:center" width="150px">
                    <h:outputText styleClass="txtBold"
                        value="#{item.info}:#{item.other}" />
                </rich:column>
            </rich:dataTable>
        </rich:tab>
    </rich:tabPanel>
</h:form>

非常感谢您查看此内容。

EDIT3 根据要求,我尝试将a4j:include 封装在h:form 中。为了使包含的内容避免嵌套 h:form,我将content.jsp 中的封闭h:form 标记替换为h:panelGrid。 当我重新运行此操作时,第二次单击 a4j:commandButton 仍然导致挂起,但我检查了萤火虫并出现了 POST http://localhost:8888/index.jsf 200 13ms,但响应为空。这有帮助吗?

【问题讨论】:

  • 检查 firefox javascript 控制台和日志
  • 发布您的页面,以便我们可以看到命令按钮数据表

标签: java jsf richfaces


【解决方案1】:

我在重新渲染命令按钮/链接时经常遇到这种情况。

您的 a4j:form 实际上正在重新渲染自身。尝试将其更改为以下内容:

<a4j:form>
    <a4j:outputPanel id="panel">
        <h:outputText style="text-align: center" value="Select " />
        <h:selectOneMenu id="mySelect" value="#{MyBacking.chosen}">
            <f:selectItems value="#{MyBacking.myList}" />
        </h:selectOneMenu>
    </a4j:outputPanel>
    <a4j:commandButton value="Retrieve" reRender="panel"/>
</a4j:form>

更新:移动您的 h:form 以包含 a4j:include。很确定它需要一个表单,当然你不能嵌套表单。

【讨论】:

  • 很好的反应,但它不起作用。如果我使用 a4j:outputPanel,我能不能忽略对 a4j:form 的需求?
  • 有趣。该按钮启动了一系列支持 bean 的工作来做不同的事情。我已经缩小了范围,以便它可以像上面一样正常工作,除非 bean 更新了一个元素,它是 a4j:included 到上面的页面中包含一个rich:dataTable。我什至不需要重新渲染 a4j:include 来显示包含的内容。我需要 a4j 的 faces-config.xml 导航内容:包含的内容吗?我会问另一个关于这个的具体问题。
  • 对不起,达摩,我没有勾选勾号,因为它就是那样,或者重新问基本相同的问题并被激怒。我没有在没有 dataTable 元素的情况下运行原始代码,所以我想我可能有两个问题,但基本上我仍然遇到了问题。问题有一个新标题。
  • 更新问题以包含 h:form 无济于事。
【解决方案2】:

修复方法是安装一个 facelets jar。见here

【讨论】:

    猜你喜欢
    • 2011-06-11
    • 2012-10-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-15
    • 1970-01-01
    相关资源
    最近更新 更多