ho aggiunto il mio commandLink (che è il link di logout) nel file di modello che non è all'interno di un form JSF .CommandLink non è in un modulo jsf perché l'ho aggiunto al modello. Tuttavia è disabilitato. C'è un modo alternativo per abilitarlo?
MainTemplate.xhtml
<h:commandLink action="#{welcomeBean.logOutSession}" class="subAnchor" value="Log Out">
</h:commandLink>
sulla pagina web che utilizza il modello, ho tutti gli elementi all'interno di una form JSF:
NewWelcome.xhtml
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
template="/webpages/templates/MainTemplate.xhtml">
<ui:define name="infomationPartOfBody">
<h:form>
<div> Here i have all the page specific content </div>
</h:form>
</ui:define>
</ui:composition>
Speravo che il logout funzionerebbe dopo aver usato il modello in una pagina con un modulo jsf. Tuttavia, il commandLink di logout mostra errore:
Log Out: Questo collegamento è disattivata in quanto non è nidificato all'interno di un modulo JSF.
So che una soluzione chiara è quella di aggiungere questo elemento separatamente in ciascuna delle pagine xhtml che utilizzerebbero il modello. Ma voglio che venga aggiunto al modello stesso in quanto è un elemento comune in tutte le pagine.
Qualsiasi aiuto sarebbe molto apprezzato. Grazie! :)
Montaggio: Ecco il codice della mia MainTemplate.xhtml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets">
<f:view>
<h:head>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.4/themes/cupertino/jquery-ui.css"/>
<script type="text/javascript" src="http://code.jquery.com/jquery-2.1.0.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<script type="text/javascript" src="../JavaScriptPages/JQueryFile.js"></script>
<title>State Transport Department- Work Schedule</title>
<link rel="stylesheet" type="text/css" href="../CSS/CompleteTemplateCSS.css"/>
<link rel="stylesheet" type="text/css" href="../CSS/templateCSS.css"/>
</h:head>
<h:body>
<div class="container">
<div class="header">
<h:graphicImage id="img" value="http://s28.postimg.org/ksnr9zs5p/header.jpg" class="img" ></h:graphicImage>
</div>
<div class="menu">
<h:outputLabel class="welcomeNote" style="font-size: x-large; color: white; float: left;
margin: 8px 0 0 5px; text-shadow:0 0 3px white" value="#{welcomeBean.fullname}" />
<ul class="ulForMyAccount">
<li> <h:outputLabel value="My Account" id="mainAnchor"/>
<ul >
<li> <h:link value="Change my Password" outcome="/webpages/ChangePasswordxhtml.xhtml" rendered="true" class="subAnchor"/> </li>
<li><h:commandLink action="#{welcomeBean.logOutSession}" class="subAnchor" value="Log Out">
</h:commandLink> </li>
</ul>
</li>
</ul>
</div>
<div class="contentBody">
<div class="menuTable">
<table class="templateBody" >
<tr>
<td class="navigationLink" > <ul><li>
<h:link value="Home" outcome="/webpages/NewWelcome.xhtml" rendered="#{welcomeBean.home}" class="mainLinks"/>
</li></ul> </td>
</tr>
<tr>
<td class="navigationLink"> <ul> <li>
<h:link value="My Schedule" outcome="/webpages/MyTask.xhtml" rendered="#{welcomeBean.myTask}" class="mainLinks"/>
</li></ul></td>
</tr>
<tr>
<td class="navigationLink"> <ul> <li>
<h:link value="Employee Work Schedule" outcome="/webpages/EmpDutySched.xhtml" rendered="#{welcomeBean.workSchedule}" class="mainLinks"/>
</li></ul></td>
</tr>
<tr>
<td class="navigationLink"><ul> <li>
<h:link value="Allocate Work" outcome="/webpages/AllocateTask.xhtml" rendered="#{welcomeBean.allocateWork}" class="mainLinks"/>
</li></ul></td>
</tr>
<tr>
<td class="navigationLink"><ul> <li>
<h:outputLabel value="Report" rendered="#{welcomeBean.report}" class="reportMenu"/>
</li></ul>
<ul>
<li><h:link value="Project Wise Report" outcome="/webpages/ProjectWiseReport.xhtml" rendered="true" class="reportItems"/></li>
<li><h:link value="Employee Wise Report" outcome="/webpages/EmployeeWiseReport.xhtml" rendered="true" class="reportItems"/></li>
</ul>
</td>
</tr>
</table>
</div>
<ui:insert name="infomationPartOfBody">
</ui:insert>
</div>
<div class="footer"></div>
</div>
</h:body>
</f:view>
</html>
Potrebbe aggiungere il codice del tuo modello MainTemplate.xhtml? – user3489875
ho aggiunto. vedere gentilmente – Shruti