以前に質問されたことは知っていますが、Balus の優れた回答 ' h:commandLink / h:commandButton is not being invoked ' + 'JSF ライフサイクル フェーズをリッスンしてデバッグする'を含むさまざまな投稿を注意深く確認した後でも、なぜ私がタブで JSF ページをレンダリングできません。
次のJsfファイルRuleAdmin2.xhtmlを正常に表示するCSSタブ「ルール」の下にPrimeFacesタブ「ルール管理」があります。そのページには、新しいルールを作成するためのボタンがあります。
バッキング Bean ターゲット属性 (ruleAdminBK.target) を新しい画面 (RuleDetails.xhtml) の値で更新し、このファイルを [ルール管理] タブに表示する必要があります。
デバッグすると、'Create New Rule' が実際に呼び出され、ターゲットに正しいファイル 'RuleDetails.xhtml' が取り込まれていることがわかりました。ただし、タブには依然として親フォーム「RuleAdmin2.xhtml」が表示されます。
[Rule] リンクをクリックすると、ページ全体が更新され、[Rules Administration] タブに正しいページ (RuleDetails.xhtml) が表示されます。
Bean が更新される前にタブがレンダリングされるように見えます。
ログ ファイルに関連情報はなく、メッセージもありません。
アイデアが不足しているため、ヒントをいただければ幸いです。
ここに私のコードがあります: 私の Facelet テンプレート (matTemplate.xhtml)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="sessionTimeout" http-equiv="refresh" content="#{session.maxInactiveInterval};url='/mat/errorExpired.xhtml?faces-redirect=true&viewName=#{view.viewId}'" />
<f:metadata>
<ui:insert name="metadata">Placeholder Data</ui:insert>
</f:metadata>
<title><ui:insert name="title">Placeholder Title</ui:insert></title>
<ui:insert name="head"></ui:insert>
<style type="text/css">
@media print {
#header, #mainmenu, #footer
{
display: none !important;
}
#wrapper {
width:760px;
border-left:0px solid #013f7a;
border-right:0px solid #013f7a;
margin:0 auto;
background:#fff;
padding:0 5px;
}
}
</style>
</h:head>
<h:body>
<h:form id="templateForm">
<div id="wrapper">
<ul id="mainmenu">
<li><h:link outcome="/home3.xhtml">Home</h:link></li>
<li><h:link outcome="/admin/rules/RuleAdmin.xhtml">Rules</h:link></li>
</ul>
<div id="content" >
<ui:insert name="content">Content</ui:insert>
</div>
</div>
<div id="footer">
<ui:insert name="footer" >
</ui:insert>
</div>
</h:form>
</h:body>
</html>
タブを定義するメイン ページ:
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core" xml:lang="en" lang="en"
xmlns:c="http://java.sun.com/jstl/core"
xmlns:p="http://primefaces.org/ui" >
<ui:composition template="./../../WEB-INF/matTemplate.xhtml">
<ui:define name="content">
<p:tabView id="tabView" dynamic="true" cache="false" activeIndex="0">
<p:tab id="tab1" title="Rules Administration">
<ui:include src="#{ruleAdminBK.target}" />
</p:tab>
</p:tabView>
</ui:define>
</ui:composition>
</html>
バッキング Bean が呼び出されます。
@Component
@Scope("session")
public class RuleAdminBK extends BaseBean {
private static final String _RULE_DETAILS = "/admin/rules/RuleDetails.xhtml";
private static final String _RULE_ADMIN = "/admin/rules/RuleAdmin2.xhtml";
private String target = _RULE_ADMIN;
public void cmdCreateNew_Click() {
setTarget(_RULE_DETAILS);
}
最後に 2 つの JSF ファイル: RuleAdmin2.xhtm
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core" xml:lang="en" lang="en"
xmlns:p="http://primefaces.org/ui">
<ui:composition>
<h:panelGroup layout="block" id="rulesAdministration">
<h:outputText id="lblStatus" value="#{ruleAdminBK.lblStatus}" />
<table width="100%">
<tr>
<td align="center"><br />
<h1>Rules Administration</h1> <br /> <h:outputLabel
id="lblErrorText1" value="#{ruleAdminBK.lblErrorText}"
styleClass="ValidateMsg" /></td>
</tr>
<tr>
<td align="right"><p:commandButton
action="#{ruleAdminBK.cmdCreateNew_Click}" value="create rule" /></td>
</tr>
</table>
</h:panelGroup>
</ui:composition>
</html>
RuleDetails.xhtml
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core" xml:lang="en" lang="en"
xmlns:p="http://primefaces.org/ui">
<f:view beforePhase="#{ruleDetailsBK.Page_BeforePhase}">
<h:outputText value="TBD" />
</f:view>
</html>