Jsf Primefaces选项卡中的页面重定向问题?
下面是我正在尝试运行的代码 ChildTemplate.xhtmlJsf Primefaces选项卡中的页面重定向问题?,jsf,jsf-2,primefaces,Jsf,Jsf 2,Primefaces,下面是我正在尝试运行的代码 ChildTemplate.xhtml <ui:composition template="../templates/home-template-new.xhtml" xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java
<ui:composition template="../templates/home-template-new.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:fn="http://java.sun.com/jsp/jstl/functions"
xmlns:p="http://primefaces.org/ui">
<ui:define name="content">
<h:outputStylesheet library="css" name="primeface_default.css" />
<p:tabView dynamic="true" cache="true" id="tabView">
<p:tab title="A">
<ui:insert name="equipList">
<ui:include src="../AList.xhtml" />
</ui:insert>
</p:tab>
<p:tab title="B">
<ui:insert name="terminationList">
<ui:include src="../BList.xhtml" />
</ui:insert>
</p:tab>
</p:tabView>
</ui:define>
</ui:composition>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
xmlns:p="http://primefaces.org/ui">
<p:dataTable value="#{bean.fetchTemp()}" var="temp" reflow="true" resizableColumns="true" liveResize="true"
id="table2">
<p:column>
........
........
</p:column>
<f:facet name="footer">
<div class="divTableFooter" align="right" id="footerDiv6">
<p:panelGrid>
<p:commandLink id="create"
action="#{bean.methodName()}">
</p:commandLink>
<h:link value="LinkName" outcome="AddRecord" />
</p:panelGrid>
</div>
</f:facet>
</p:dataTable>
</ui:composition>
下面是BList.xhtml
<ui:composition template="../templates/home-template-new.xhtml"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:fn="http://java.sun.com/jsp/jstl/functions"
xmlns:p="http://primefaces.org/ui">
<ui:define name="content">
<h:outputStylesheet library="css" name="primeface_default.css" />
<p:tabView dynamic="true" cache="true" id="tabView">
<p:tab title="A">
<ui:insert name="equipList">
<ui:include src="../AList.xhtml" />
</ui:insert>
</p:tab>
<p:tab title="B">
<ui:insert name="terminationList">
<ui:include src="../BList.xhtml" />
</ui:insert>
</p:tab>
</p:tabView>
</ui:define>
</ui:composition>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:fn="http://java.sun.com/jsp/jstl/functions"
xmlns:p="http://primefaces.org/ui">
<p:dataTable value="#{bean.fetchTemp()}" var="temp" reflow="true" resizableColumns="true" liveResize="true"
id="table2">
<p:column>
........
........
</p:column>
<f:facet name="footer">
<div class="divTableFooter" align="right" id="footerDiv6">
<p:panelGrid>
<p:commandLink id="create"
action="#{bean.methodName()}">
</p:commandLink>
<h:link value="LinkName" outcome="AddRecord" />
</p:panelGrid>
</div>
</f:facet>
</p:dataTable>
</ui:composition>
........
........
现在让我来定义这个问题
现在我的活动选项卡是B,当我单击
或
时,它将重定向并显示选项卡A,而它应该在当前活动选项卡B
中显示AddRecord.xhtml页面
我的代码有什么问题?有人可以推荐吗?您可以将
activeIndex
属性添加到tabview
组件中,并使用p:ajax
编写tabchange
事件。请检查以下代码
<h:outputStylesheet library="css" name="primeface_default.css" />
<p:tabView dynamic="true" cache="true" id="tabView" activeIndex="#{bean.tabIndex}">
<p:ajax event="tabChange" listener="#{bean.onTabChange}" />
<p:tab title="Equipment" >
<ui:insert name="equipList">
<ui:include src="../AList.xhtml" />
</ui:insert>
</p:tab>
<p:tab title="Termination">
<ui:insert name="terminationList">
<ui:include src="../BList.xhtml" />
</ui:insert>
</p:tab>
</p:tabView>
希望这将帮助您请改进您的问题。这不是一个简单的问题。您提到了“AddRecord.xhtml”,但它不存在。您的模板不存在(它是否发挥作用?否?删除它)。。。您的代码包含许多基本问题(
action=“bean.methodName()”
。从简单的事情开始,首先让它起作用。这是打字错误action=“bean.methodName()”
如果你仔细检查了这个问题,你会发现我已经提到了
。如果有基本的错误,页面如何呈现?因此你可以说有一些打字错误,但没有基本的错误。不是所有的“基本”错误都会导致页面无法呈现……而“AddRecord”确实是我的一个遗漏,对此表示抱歉。如果有这样的输入错误,我不打算进一步调查。任何东西都可能是输入错误(我如何区分输入错误和基本错误?创建一个完全100%运行的mcve,而不是部分复制/粘贴/编辑…viewSource中的锚定标记显示了什么。请在p:tabView中添加activeIndex属性并将其指向#{bean.activeIndex}activeIndex在适当范围的managedBean中应为int,以便在重新呈现页面或部分页面时不会隐藏当前选项卡。@Mahendranayyarsamykandair任何您知道的示例。如果这真的正是OP所需要的,那么这个问题包含的噪音可能会很大。整个模板内容都不起作用。addRecord页面由于存在对“addRecord”的完整页面“get”请求,因此在选项卡B中加载仍然不会发生。然后它是一个简单的副本。。。