357 Lotus blogs updated hourly. Who will post next? Home | Downloads | Events | Pods | Blogs | Search | myPL | About 
 
Latest 7 Posts
Web Components – Entering the ShadowDOM….
Wed, Jul 9th 2014 177
Speaking at MWLUG 2014: Write once, run anywhere – Angular.js in XPages
Tue, Jul 8th 2014 223
Hi Chicago – what changed?
Wed, Jul 2nd 2014 250
Angular.js in XPages #6 – A People Manager CRUD application
Sun, Jun 1st 2014 406
Angular.js in XPages #5 – Routing
Sun, May 25th 2014 305
WebSockets comes to XPages!! Awesome – Awesome – Awesome
Tue, May 20th 2014 452
Angular.js in XPages #4 – Using Domino Data
Sun, May 18th 2014 385
Top 10
Arguably the most dangerous thing you could ever do in XPages – let other people use your eval() in their SSJS
Tue, Jun 18th 2013 1014
Why learning JavaScript is more critical to XPage developers than Java
Wed, Mar 26th 2014 918
An open letter to Mr. NotesIn9
Wed, Apr 2nd 2014 605
EXTJS in XPages #14 – Grid editing and saving data via REST CRUD
Thu, Aug 1st 2013 572
Adding custom HTTP headers to Domino R9 using IBM HTTP Server (IHS)
Sun, Apr 20th 2014 540
EXTJS in XPages #13: Totaling your columns with a groupingSummary
Sun, Jun 30th 2013 537
Angular.js in XPages #1 – Using the right IDE for development
Sun, Apr 27th 2014 498
And the gloves are off……
Mon, Mar 31st 2014 479
Why using XPages Partial Refresh is sometimes easy for developers and bad for users
Tue, Mar 4th 2014 469
Prototypal inheritance of SSJS across the whole server in XPages
Sun, Mar 2nd 2014 456


jQuery in XPages #9 – PageSlide
MarkyRoden    

In this article I will describe how to implement and provide examples of use the jQuery plugin PageSlide within an XPage. This is a fairly simple plugin with very few parameters but provides an alternate method for displaying information to users

PageSlide.js

Demonstration

The XPages integration of PageSlide is demonstrated here

Download

The demonstration database can be downloaded from the link above or from here

Introduction

PageSlide by Scott Robin is a simple plugin which allows external content to be displayed in a sidebar on the page. There are only two parameters, direction (left or right) and modal (true or false).  It is really quite simple. As you will see my implementation does not use XPage XML markup to add resources or to activate the capability. I found that this caused issues in the browser. The capability works well using the example code from the website, applied in an XPage.

PageSlide showing data from another XPage to the side of the main

PageSlide showing data from another XPage to the side of the main

How does it work?

I added jQuery, the pageslide js library and the pageslide.css stylesheet to my database through the WebContents folder and added them to to my XPage via script and link tags.

		  <script src="js/jquery.pageslide.js"></script>
		  <script src="js/jquery-1.7.1.min.js"></script>
		  <link rel="stylesheet" type="text/css" href="css/jquery.pageslide.css" />

The basic concept works like this:

  • You create a link on the page
    • < a href=”xSomething.xsp” class=”aClass”>
  • You select the link in question
    • $(“a.aClass”).
  • You pageslide it
    • pageslide({direction: “left”, modal: false})

	<a href="xPageSlide_1.xsp" class="myClass">Display user information</a>
	<script>$("a.myClass").pageslide({ direction: "left", modal: false});</script>

When clicking on the link this produces the effect of opening xPageSlide_1.xsp in the right hand panel of the screen (direction: left moves everything to the left).
If the modal = true paramater is included then the “slide” can only be closed programmatically. This forces user interaction with the information. If not included or modal = false then clicking anywhere in the screen will make the slide disappear.

And that is pretty much it….. nothing complicated this week :)

More examples
I created a custom control with custom parameters so that the capability can be added to any page.

Custom Control properties

Custom Control properties

The example page contains a demo of this custom capability and it is build like this:

  • A link with a dynamic href is added to the form along with
  • A scriptBlock which adds the PageSlide capability to the link passing the custom parameters as necessary.

<xp:link escape="true" text="CompositeData example"
	id="compositeDataExample"
	value="${compositeData.content}" styleClass="marky">
</xp:link>
<xp:scriptBlock id="scriptBlock1">
	<xp:this.value><![CDATA[
		bModal = "#{compositeData.modal}"
		bModal == "false" ? false : true
		$("[id$=compositeDataExample]").pageslide(
			{ 	direction: "#{compositeData.direction}",
				modal: bModal
			});
	]]></xp:this.value>
</xp:scriptBlock>

The other example I created involves using sessionScope variables to look up information dynamically.

sliding in a new XPage with dynamic content

sliding in a new XPage with dynamic content

There is a hidden anchor tag on the form which is has PageSlide attached to it in a similar way as described above. It is hidden becasue we are going to “click” it programmatically when a user is selected in the comboBox.

<a href="xPageSlide_1.xsp" class="marky2" style="display:none">Display user information</a>
<script>$("a.marky2").pageslide({ direction: "right", modal: true });</script>

The combobox has a simple SSJS lookup formula showing the first column of the AllContacts view
#{javascript:@DbColumn(“”, “AllContacts”, 1)}

<xp:comboBox id="comboBox1" defaultValue="Pick a person">
	<xp:selectItem itemLabel="Pick a person" itemValue="Pick a person"></xp:selectItem><xp:selectItems>
		<xp:this.value><![CDATA[#{javascript:@DbColumn("", "AllContacts", 1)}]]></xp:this.value>
	</xp:selectItems>
	<xp:eventHandler event="onchange" submit="true" refreshMode="partial" refreshId="computedField1">
	</xp:eventHandler>
</xp:comboBox>

In the onChange event I perform a partial refresh of the computedField1. computedField1 looks like this and returns some JavaScript which triggers the link “.click()”

<xp:text escape="false" id="computedField1">
	<xp:this.value><![CDATA[#{javascript:var person = sessionScope.person=getComponent("comboBox1").getValue();
		var disp = "<script>$('a.marky2').click()</script>";
		disp2 = (person == "Pick a person" ? "" : disp);
		return disp2
	}]]>
	</xp:this.value>
</xp:text>

  • If a person is picked the computed field is refreshed
    • The computed field sets a sessionScope variable based on the value selected
      • var person = sessionScope.person=getComponent(“comboBox1″).getValue()
    • The refreshed value contains a script tag which executes when the refresh is loaded.
      • var disp = “// “;
        disp2 = (person == “Pick a person” ? “” : disp);
        return disp2
    • $(‘a.marky2′).click() clicks the hidden link opening the page slide

The xPageSlide_1.xsp page takes the sessionScope variable and looks up the user’s information based on the variable set in the computedField1 above.

<xp:div id="div1" style="display:nonex">
				    <h2 style="color: white">User Information</h2>
				    <xp:br></xp:br><xp:br></xp:br>
					<xp:text escape="true" id="computedField1"><xp:this.value><![CDATA[#{javascript:var per = sessionScope.person;
@DbLookup(@DbName(), "vwContacts", per, 4)}]]></xp:this.value></xp:text>

					<xp:br></xp:br>
					<xp:br></xp:br>
					<xp:text escape="true" id="computedField5"><xp:this.value><![CDATA[#{javascript:var per1 = sessionScope.person;
@DbLookup(@DbName(), "vwContacts", per1, 5)}]]></xp:this.value></xp:text>
					<xp:br></xp:br>
					<xp:br></xp:br>
					<xp:text escape="true" id="computedField3"><xp:this.value><![CDATA[#{javascript:var per2 = sessionScope.person;
@DbLookup(@DbName(), "vwContacts", per2, 6)}]]></xp:this.value></xp:text>
					<xp:br></xp:br>					<xp:br></xp:br>
										<xp:button id="button1" value="Close" style="display: block">
		<xp:eventHandler event="onclick" submit="false">
			<xp:this.script><![CDATA[parent.$.pageslide.close()]]></xp:this.script>
		</xp:eventHandler></xp:button><xp:br></xp:br>

</xp:div>

and with a little styling we are done for a consistent look and feel

<style>
DIV {
    background-color: #333333;
    color: #FFFFFF;
    height: 100%;
    padding: 20px;
    position: fixed;
    top: 0;
    width: 260px;
    z-index: 999999;
}

H2 { color: white }
</style>

Conclusion

I could easily see myself using PageSlide if I wanted to use a hidden menu or if I wanted to have a status update bar running in the background of my webpage which was accessed and made visible to the user when they wanted it to be there.

This is certainly the simplest plugin I have written about, but this is a very elegant solution to displaying hidden information to a user on demand.

Demonstration

The XPages integration of PageSlide is demonstrated here

 




---------------------
http://xomino.com/2012/05/08/jquery-in-xpages-9-pageslide/
May 08, 2012
69 hits



Recent Blog Posts
177


Web Components – Entering the ShadowDOM….
Wed, Jul 9th 2014 9:18p   Mark Roden
Web Components – the future You should first ground yourself on Web Components and read this article on Web Components and concepts, ShadowDOM, imports, templates, custom elements by Todd Motto. Then listen to this Podcast (thanks to Steve for pointing it out) - Web Components with Peter Gasston Once you have read/listened you will have some idea and concept about Web Components and how they are the future….. But what I wanted to show briefly was how to enable the ShadowDOM in C [read] Keywords: agent javascript podcast
223


Speaking at MWLUG 2014: Write once, run anywhere – Angular.js in XPages
Tue, Jul 8th 2014 10:55a   Mark Roden
I am very fortunate and excited to announce that I have been accepted to speak at MWLUG 2014. MWLUG will always have a fond place in my heart because I had my first speaking session there back in 2012 and had such a fantastic time it pushed me to do more. I will speak speaking about Angular.js and the opportunity it avails us as Web Developers. We all know IBM Domino is arguably to world’s most secure and mature NoSQL database. So we will take a look at how we can use it like a NoSQL [read] Keywords: domino ibm xpages application applications database development server
250


Hi Chicago – what changed?
Wed, Jul 2nd 2014 7:16a   Mark Roden
Well it has been on the cards now for 6 months but we finally did it. My family and I moved from Virginia to Chicago and I have started working out of the PSC office in Schaumburg, IL. I was asked nearly 18 months ago if I would consider moving, but for mostly family reasons it took a year or so to organize and agree this was the right thing to do for my career and just as importantly for the family. Working at home has been wonderful for the past two years. But it was also a little limiting [read] Keywords: office
406


Angular.js in XPages #6 – A People Manager CRUD application
Sun, Jun 1st 2014 6:58p   Mark Roden
In this article I will bring together everything discussed in the first 5 articles and demonstrate how to create you first basic CRUD application using Angular.js and XPages. Previous articles Angular.js in XPages #5 – Routing Angular.js in XPages #4 – Using Domino Data Angular.js in XPages #3 – The first app Angular.js in XPages #2 – Setting up a Webstorm / Domino development environment Angular.js in XPages #1 – Using the right IDE for development Introduction In the last article w [read] Keywords: domino ibm ods R8 xpages application database development firefox iphone javascript properties server xml
305


Angular.js in XPages #5 – Routing
Sun, May 25th 2014 6:52p   Mark Roden
In this article I will show how angular using routing to create a bookmarkable URL string and how that fits together with additional controllers. This will start us on the path to creating our basic CRUD application. This article is based on the Routing and Multiple views tutorial  Routers Way back when the world was young (in internet terms a couple of years ago), when single page apps were all the rage, it was noticed that there was a significant drawback to only having one URL index.html; [read] Keywords: ibm xpages ajax application database xml
452


WebSockets comes to XPages!! Awesome – Awesome – Awesome
Tue, May 20th 2014 6:49p   Mark Roden
In this article I will introduce and discuss the OpenNTF WebSockets OSGI plugin by Mark Ambler. The websocket plugin posted to Mark Ambler is based on the http://java-websocket.org/ project. I realize I am not the first person to play with a websocket server on top of a domino database. I know of at least 4 other people who have at least done their own POC for this. But this is the first time I have got my hands on it :) I’m a little excited…… Playing websockets in XPages wit [read] Keywords: agent domino ibm notes rich text sametime xpages application community database integration java javascript network openntf server twitter xml




385


Angular.js in XPages #4 – Using Domino Data
Sun, May 18th 2014 6:36p   Mark Roden
In this article I will demonstrate how to use Angular.js to access Domino Data and display it in place of the hard coded data we used in the previous article. Introduction This article is based off the Angular developer tutorial on XHR and dependency injection . It is essential you go and read that article before continuing. It explains how dependency injection works, why it is used and about Angular services. Modifying the controller In our previous article we used a hard coded json string [read] Keywords: agent domino ibm ldd lotus lotusscript ods xpages ajax application database development java security server
390


Angular.js in XPages #3 – The first app
Sun, May 11th 2014 6:40p   Mark Roden
In this article I will recreate one of the simple Angularjs.org developer tutorials and relate it to how we would build an equivalent XPages application. Create the database As described in the previous article, set up a Domino database with an ODS. Then link your Webstorm to the new ODS structure. Download the Angular code from https://angularjs.org/ it will be an 8M download. Opening the zip file you will see a lot of “angular files”. These are “Dependency files” [read] Keywords: domino ods xpages application applications database development dojo google java server xml
327


Mastering XPages v2 – Review
Sat, May 10th 2014 8:55a   Mark Roden
In this article I will put forth my case as to why you need to buy Mastering XPages v2 – even if you already own v1 Introduction Maybe this book should be entitled – “So you think your an XPages expert? You are not a Master !” Clearly I am not a Master – and couldn’t possibly hope to be one and that is why *I* need this book….. The writing style Perhaps not the most obvious place to start but to me a significant one. There are many styles of writing for [read] Keywords: xpages application applications blogger community css development dojo java javascript mobile properties server
335


jQuery Promises – Taking action .when() multiple ajax calls are complete
Wed, May 7th 2014 6:52p   Mark Roden
jQuery.when() – “Provides a way to execute callback functions based on one or more objects, usually Deferred objects that represent asynchronous events” https://api.jquery.com/jQuery.when/ Wouldn’t it be nice to be able to know when two ajax calls are both complete – and then process the data returned from both, at the same time ? Callbacks Off the top of my head I would normally achieve this using a callback – and I have done so in some of my ExtJS in XPage [read] Keywords: xpages ajax




Created and Maintained by Yancy Lent - About - Blog Submission - Suggestions - Change Log - Blog Widget - Advertising - Mobile Edition