【发布时间】: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:commandButton 和rich: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 控制台和日志
-
发布您的页面,以便我们可以看到命令按钮和数据表