【发布时间】:2014-08-06 16:22:48
【问题描述】:
我有一个.xhtml 页面,其中包含许多其他.xhtml 页面,每个页面都通过特定操作呈现
<h:form>
<div id="wrapper">
<h:commandLink
onclick="hideWrapper()">
<f:ajax listener="#{Bean.createListener}" event="action"
render=":parent-panel" />
<div class="test">
<div class="icon"></div>
<div class="title">#{msgs.create_new_bean}</div>
<span>#{msgs.create_your_bean}</span>
</div>
</h:commandLink>
<h:commandLink >
<f:ajax listener="#{Bean.historyListner}" event="action"
render=":parent-panel" />
<div class="History1">
<div class="icon"></div>
<div class="title">#{msgs.history}</div>
<span>#{msgs.history}</span>
</div>
</h:commandLink>
</div>
</h:form>
<h:panelGroup id="parent-panel">
<c:if test="#{Bean.activeEditFlag}">
<h:panelGroup id="active-page">
<ui:include src="active.xhtml" />
</h:panelGroup>
</c:if>
<c:if test="#{Bean.createFlag}">
<h:panelGroup id="create-page">
<ui:include src="create.xhtml" />
</h:panelGroup>
</c:if>
<c:if test="#{Bean.activeEditFlag}">
<h:panelGroup>
<ui:include src="edit.xhtml" />
</h:panelGroup>
</c:if>
<c:if test="#{Bean.historyFlag}">
<h:panelGroup id="history-page">
<ui:include src="history.xhtml" />
</h:panelGroup>
</c:if>
</h:panelGroup>
每个包含的页面都包含h:commandLink 或h:selectBooleanCheckbox 之类的组件,有两个页面必须从第一次render=true 开始呈现,这些页面在 ajax 上运行良好,但是当涉及到任何其他页面时从 render=false 到 ture,它们被渲染但包含 ajax 的组件不工作。有什么想法吗??
【问题讨论】:
-
您似乎在包含的 xhtml 文件中有单独的
h:forms。请尝试将“父面板”嵌套在单个表单中,从包含的 xhtml 文件中删除内部表单,并仅在f:ajax操作中执行必要的组件。我试图避免重新渲染h:forms。 -
我认为这也是问题所在,但是很难删除那些表格,还有其他想法吗??
-
@tt_emrah 重新渲染表格是什么意思?表单重新渲染的主要问题是什么?
-
在 ajax 事件之后,您执行
render=":parent-panel"并且有嵌套在“父面板”中的表单。很多次我都看到在初始页面加载后渲染h:form会与 ajax 请求混淆,但如果不亲自尝试,我无法 100% 确定。
标签: javascript ajax jsf-2