我在 Spring web flow 中使用了磁贴。这是我的标准 jsf 文件。
标准.xhtml
<f:view contentType="text/html">
<h:head >
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Nagra Employee Leave Application</title>
<link rel="stylesheet" href="${request.contextPath}/styles/blueprint/screen.css" type="text/css" media="screen, projection" />
<link rel="stylesheet" href="${request.contextPath}/styles/blueprint/print.css" type="text/css" media="print" />
<link rel="stylesheet" href="${request.contextPath}/styles/le-frog/jquery-ui-1.8.2.custom.css" type="text/css" media="screen" />
<ui:insert name="headIncludes"/>
<style>
</style>
</h:head>
<h:body style="background:#343433" >
<div class="container" style="background:white;">
<a href="#{request.contextPath}"><img src="${request.contextPath}/images/rubon1.jpg" height="200" width="950" alt="Spring Travel"/></a>
<div>
<div id="local" class="span-4 colborder" style="padding-top: 20px;
padding-left: 21px;">
<h3>Nagra Vision</h3>
<ui:insert name="notes"/>
</div>
<div class="span-19 last" style="width: 720px;">
<ui:insert name="content"/>
</div>
</div>
<div>
<a href="http://www.nagra.com">
<img src="${request.contextPath}/images/nagra_footer.png" alt="Powered by Nagra-India" />
</a>
</div>
</div>
</h:body>
登录.xhtml
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
template="/WEB-INF/layouts/standard.xhtml">
<ui:define name="content">
<h:form style="margin-top:10px;">
<div>
<h:outputLabel for="username">Username: </h:outputLabel>
<h:inputText id="username" value="#{userInfo.username}"> </h:inputText>
</div>
<div>
<h:outputLabel for="password">Password: </h:outputLabel>
<h:inputSecret id="password" value="#{userInfo.password}">
</h:inputSecret>
</div>
<div>
<h:selectBooleanCheckbox id="leavetype"
value="#{userInfo.loginperson}">
<f:selectItems value="#{referenceData.loginPersonOptions}" />
</h:selectBooleanCheckbox>
<h:outputLabel for="password">Select you are a manager</h:outputLabel>
</div>
<div>
<p:commandButton id="Signin" action="click" value="Sign In"
style="margin-left:80px;" />
</div>
</h:form>
</ui:define>
主页.xhtml
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui"
template="/WEB-INF/layouts/standard.xhtml">
<ui:define name="notes">
<h:outputLabel for="employee">${loginperson.username}</h:outputLabel>
<h:form>
<div> <h:commandLink value="Sick Leave" action="sickleave" id="sickleave" /></div>
<div> <h:commandLink value="Paid off Leave" action="paidleave" id="paidleave" /></div>
<div> <h:commandLink value="Logout" action="logout" id="logout" /></div>
</h:form>
</ui:define>
<ui:define name="content">
<h2 style="font-size: 16px; font-weight: bold; margin-top: 100px;">Available
Leave</h2>
<h:dataTable value="#{leaveavailable}" var="a"
styleClass="order-table" headerClass="order-table-header"
rowClasses="order-table-odd-row,order-table-even-row"
columnClasses="order-table-odd-column,order-table-even-column">
<h:column>
<f:facet name="header">
Sick Leave
</f:facet>
#{a.totalSickLeave}
</h:column>
<h:column>
<f:facet name="header">
Paidoff Leave
</f:facet>
#{a.totalPaidoffLeave}
</h:column>
</h:dataTable>
</ui:define>
这里一旦用户登录用户将看到mainpage.xhtml。用户进入主页后,如果他按下浏览器的后退按钮,它会将我带到登录页面。所以我需要禁用后退按钮。我不要在哪里添加javascript代码以禁用浏览器后退按钮。我必须添加mainpage.xhtml还是standard.xhtml。
我必须添加什么java脚本来禁用后退按钮