我有一个.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的组件不起作用。任何想法??
答案 0 :(得分:0)
我找到了两个解决这个问题的方法,但是他们更多的是解决这个问题,因为正如我所理解的那样,我引用“在初始页面加载混乱后使用ajax请求呈现h:表单”,而对于我的情况,我不能从包含的页面中删除h:表单。因此我使用c:if
代替f:subview
而不是render
属性,您可以在subview with including pages查看此属性
另一个解决方案是使用javascript将页面附加到主页
$('.main-button2').click(function(e) {
$(".parent-panel").empty();
$.get("../history.xhtml", function(data) {
$(".parent-panel").append(data);
});
});