I have used tiles in Spring web flow.This is my standard jsf file.
standard.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>
Login.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>
mainpage.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>
here once the user login in the user will see the mainpage.xhtml.After the user getting into the mainpage,if he press the back button of the browser it takes me to the login page.So I need to disable the back button.I do no where to add the javascript code to disable the browser back button.Whether I have to add in mainpage.xhtml or in standard.xhtml.
What java script i have to add to disable the back button
You can’t disable the back button. You can, however, remove the current document from the browser history and replace it with your desired document by using
window.location.replace. Keep in mind that you need to use AJAX in this case, sincereplacehas to be called from the document you want to replace.Instead of meddling with JavaScript and trying to mangle the user’s browser, why don’t you check on the server side whether the user is already logged in and redirect him to your main page?