【发布时间】:2015-11-20 07:45:58
【问题描述】:
这是我要运行的代码
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.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>
这里是 BList.xhtml
<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,当我点击 <p:commandLink/> 或 <h:link /> 它正在重定向并显示标签 A 而它应该显示 AddRecord.xhtml 页面在当前活动标签B。
我的代码有什么问题?有人可以推荐吗?
【问题讨论】:
-
请改进您的问题。它不是minimal reproducible example。您提到了“AddRecord.xhtml”,但它无处不在。您有一个无处可去的模板(它起作用了吗?没有?删除它)...您的代码包含许多基本问题(
action="bean.methodName()"。从简单的事情开始,然后首先使其工作。 -
这是错字
action="bean.methodName()",如果您彻底检查问题,您会得到我已经提到的<h:link value="LinkName" outcome="AddRecord" />。如果出现基本错误,如何呈现页面?所以你可以说有一些错字,但不是基本错误。 -
并非所有的“基本”错误都会导致页面无法呈现......而且“AddRecord”确实是我这边的一个遗漏,对此感到抱歉。如果有这样的错别字,我不会进一步调查。任何东西都可能是拼写错误(我如何区分拼写错误和基本错误?创建一个完全 100% 运行的 mcve,而不是部分复制/粘贴/编辑...
-
中 viewSource 的锚标记显示什么。请在 p:tabView 中添加 activeIndex 属性并将其指向 #{bean.activeIndex} activeIndex 应该是 int 在您适当范围的 managedBean 中,以便在重新渲染页面或部分页面时不会隐藏当前选项卡。
-
@MahendranAyyarsamyKandiar 你知道的任何例子。
标签: jsf jsf-2 primefaces