Xpages form Login with session variable

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">


	<xp:span style="font-weight:bold;font-size:18pt">UserID</xp:span>
	<xp:span style="font-weight:bold;font-size:18pt"> Login</xp:span>
	<xp:br></xp:br>

	<xp:table>
		<xp:tr>
			<xp:td>
				<xp:inputText id="userName1" style="width:275.0px"
					required="true" value="#{TestLoginJavaBean.userName}"
					disableClientSideValidation="true">
				</xp:inputText>
			</xp:td>
			<xp:td>
				<xp:label value="#{TestLoginJavaBean.message}" id="errMessage"
					style="width:124.0px;color:rgb(117,11,11);font-weight:bold"></xp:label>
			</xp:td>
		</xp:tr>
		<xp:tr>
			<xp:td>
				<xp:button value="Login" id="button1">
					<xp:eventHandler event="onclick" submit="true"
						refreshMode="complete" immediate="false" save="true" id="eventHandler1">
						<xp:this.action><![CDATA[#{javascript:TestLoginJavaBean.doLoginUser()}]]></xp:this.action>
					</xp:eventHandler>
				</xp:button>
			</xp:td>
			<xp:td></xp:td>
		</xp:tr>
	</xp:table>
	<xp:this.navigationRules>
		<xp:navigationRule outcome="xsp-success" viewId="/xpwelcome.xsp"></xp:navigationRule>
	</xp:this.navigationRules>

</xp:view>





Grab this XSnippet to work with updated Java code added earlier to make available session items throughout your pages; item that can be used to create own custom error messages... See brief instructions for more info.

Brief Instructions:

(1) Create view called URLAccessView
(2) Add Column named UserID
(3) Add preferred record in that column
(4) Copy and Paste above XML code into a New Xpages form
(5) Grab TestLoginJavaBean code added earlier, create own package to encapsulate code
(6) Make some entries to your facesConfig file, to include TestLoginJavaBean.java class
(7) Create an additional Xpages form with XML below, call it xpwelcome
(8) Run this bad boy in your browser and search your value added to UserID column in URLAccessView

xpwelcome.xsp

<?xml version="1.0" encoding="UTF-8"?>
<xp:view xmlns:xp="http://www.ibm.com/xsp/core">
<xp:table>
<xp:tr>
<xp:td>
<xp:label id="label2" value="Logged in As:"
style="font-weight:bold;color:rgb(240,222,0);background-color:rgb(0,64,128)"></xp:label>
</xp:td>
<xp:td>
<xp:label value="#{sessionScope.TestLoginJavaBean.userName}"
id="label1"
style="background-color:rgb(0,64,128);color:rgb(255,255,0);width:120.0px">
</xp:label>
</xp:td>
</xp:tr>
</xp:table>
<xp:br></xp:br>

</xp:view>

//...
//...

XPages
Köll S Cherizard
February 13, 2014 10:21 PM
Rating
33

All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.



No comments yetLogin first to comment...