359 Lotus blogs updated hourly. Who will post next? Home | Downloads | Events | Pods | Blogs | Search | myPL | About 
 
Latest 7 Posts
Binding jQuery code to an XPages partialRefresh using DOM Mutation events
Wed, Oct 29th 2014 181
Using jQuery .when() to trigger a screen update after select2 has loaded
Tue, Oct 28th 2014 116
Integrating the Bluemix Watson Translation service into an XPages application
Sun, Oct 19th 2014 347
Oh duh, that is why Node Package Manager (npm) is so cool
Tue, Oct 14th 2014 338
Create your own Watson Q and A example with Bluemix, Webstorm and Jazz Hub
Sun, Oct 12th 2014 760
Getting into IBM Bluemix….this could be interesting
Wed, Oct 8th 2014 268
Opening an XPage in XPiNC and passing Query_String parameters
Tue, Sep 30th 2014 199
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 1274
Create your own Watson Q and A example with Bluemix, Webstorm and Jazz Hub
Sun, Oct 12th 2014 760
Running an XPages/Angular.js application on a Bluemix site
Wed, Sep 17th 2014 557
Going to MWLUG 2014? Buy Dave Leedy a beer
Sun, Aug 24th 2014 451
Angular.js in XPages #7 – Writing better code using Services
Sun, Aug 3rd 2014 428
EXTJS in XPages #13: Totaling your columns with a groupingSummary
Sun, Jun 30th 2013 405
Speaking at MWLUG 2014: Write once, run anywhere – Angular.js in XPages
Tue, Jul 8th 2014 401
Taking back productivity in Domino Designer (a NotesIn9 production)
Tue, Jul 29th 2014 394
Hi Chicago – what changed?
Wed, Jul 2nd 2014 374
Web Components – Entering the ShadowDOM….
Wed, Jul 9th 2014 349


HTML5 drag and drop demonstration in an XPage
MarkyRoden    

I saw an article on HTML5 drag and drop and wondered how hard it would be in XPages.

Demonstration

Here is a link to the working demo of HTML5 drag and drop in an XPage – this is FF and Chrome only as drag/drop is not supported until IE10

How does it work?

I created an XPage and added a simple data table

Data Table

XPages Data Table

 

Going off the text in the article I tried to add the events to the Fruit label column – unfortunately you cannot add custom attributes to an xp:text

Cannot add custom attributes to an <xp:text

Cannot add custom attributes to an <xp:text

 

So once again – back to using dojo selectors to get what we want.

The HTML generated by the XPage creates all the fruit labels (Oranges, Bananas, Apples) with an id=blah:_1blah ending in “someFruit”

<tr><td class="xspColumn"><span id="view:_id1:_id2:_id31:viewPanel1:0:column3:someFruit" class="xspTextComputedField">Oranges</span></td>
<td class="xspColumn"><span id="view:_id1:_id2:_id31:viewPanel1:0:column1:computedField2" class="xspTextComputedField">2.0</span></td>
<td class="xspColumn"><span id="view:_id1:_id2:_id31:viewPanel1:0:column2:computedField3" class="xspTextComputedField">4</span></td>
</tr>
<tr><td class="xspColumn"><span id="view:_id1:_id2:_id31:viewPanel1:1:column3:someFruit" class="xspTextComputedField">Bananas</span></td>
<td class="xspColumn"><span id="view:_id1:_id2:_id31:viewPanel1:1:column1:computedField2" class="xspTextComputedField">1.0</span></td>
<td class="xspColumn"><span id="view:_id1:_id2:_id31:viewPanel1:1:column2:computedField3" class="xspTextComputedField">2</span></td>
</tr>

We can get a handle on these labels using dojo.query(“[id$=someFruit]“) which will get all elements with an id attribute ending in “someFruit”

Once we have all of those elements we can add a draggable and ondragstart attribute to them easily using dojo.attr

			dojo.query("[id$=someFruit]").forEach( function(node){
				 dojo.attr(node, "draggable", "true");
				 dojo.attr(node, "ondragstart", "dragIt(event);");
			});

Then we just need somewhere to drop them…
I added the same DIV elements from the example to the XPage

				<xp:td>
					<div id="place1" ondrop="dropIt(event);"
						ondragover="event.preventDefault();">
					</div>
				</xp:td>
				<xp:td>
					<div id="place2" ondrop="dropIt(event, true);"
						ondragover="event.preventDefault();">
					</div>
				</xp:td>

and added the javascript functions to a scriptblock at the bottom of the page

	//function called when drag starts
		function dragIt(theEvent) {
			//tell the browser what to drag
			theEvent.dataTransfer.setData("Text", theEvent.target.id);
		}

		//function called when element drops
		function dropIt(theEvent, keepMe) {
			//get a reference to the element being dragged
			var theData = theEvent.dataTransfer.getData("Text");
			//get the element
			var theDraggedElement = document.getElementById(theData);

			//add it to the drop element
			if (keepMe){
				//Add a clone of the element to the field - rather than move it
				var newObj=dojo.clone(theDraggedElement)
				theEvent.target.appendChild(newObj);
			} else {
				theEvent.target.appendChild(theDraggedElement);
			}
			//Add a new line for visual line up
			var theBR=document.createElement("br")
			theEvent.target.appendChild(theBR);
			//instruct the browser to allow the drop
			theEvent.preventDefault();
		}

I changed the example slightly to add a clone capability rather than just drag and drop

Drag and Drop example 1

Drag and Drop example 1 (Move)

 

Dragging to the first box “moves” the label

Drag and Drop example 2 (Clone)

Drag and Drop example 2 (Clone)

 

Dragging the label to the second box create a copy of it using dojo.clone(node)

Conclusion

This is merely a prototype but demonstrates nicely the new and exiting capabilities of HTML5 without having the need for a dojo or jQuery library to do the drag/drop for you

Demonstration (again)

Here is a link to the working demo of HTML5 drag and drop in an XPage

 




---------------------
http://xomino.com/2012/03/27/html5-drag-and-drop-demonstration-in-an-xpage/
Mar 27, 2012
65 hits



Recent Blog Posts
181


Binding jQuery code to an XPages partialRefresh using DOM Mutation events
Wed, Oct 29th 2014 7:38p   Mark Roden
Introduction In this article I will demonstrate how to bind to the event which triggers on the completion of an XPages partialRefresh. Using that binding we will then be able to action to contents of the newly added partialRefresh DOM elements. Background In multiple articles I have discussed the use of the onComplete event of a programmatically triggered partialRefresh to be able to re-apply a jQuery plugin’s bindings to an area of an XPage. This works very nicely and integrates with the [read] Keywords: domino xpages application css dojo server
116


Using jQuery .when() to trigger a screen update after select2 has loaded
Tue, Oct 28th 2014 5:58a   Mark Roden
We have an XPage with over 100 complex fields on it and we found that applying Select2 to it took a noticeable amount of time – tangible to the user. Users would see the original “SELECT” fields before the nicer select2 style was applied. So we determined to hide all the fields on the form until select2 was finished loading, then show them all select2’d. The problem was that would could not find an obviously way to do this. I was looking for a parameter within the s [read] Keywords: xpages css
347


Integrating the Bluemix Watson Translation service into an XPages application
Sun, Oct 19th 2014 7:07p   Mark Roden
In this article I will demonstrate how to integrate the Bluemix Watson Translation service into a functioning XPages application. Bluemix Watson Translation Service Following on from one from my previous posts on the subject I have been looking for a good workable example of using a Bluemix service within an XPages application. As I said before this is as much an exercise in me learning more about node.js and Bluemix as anything else – but I also love being able to share. Based on the [read] Keywords: domino ibm notes xpages ajax application development server xml
338


Oh duh, that is why Node Package Manager (npm) is so cool
Tue, Oct 14th 2014 9:07p   Mark Roden
I am in the process of playing with Bluemix and part of the reason or this is to learn more about node.js. It is really cool to learn something new and also to broaden the mind. But I digress – Node Package Manager (npm) makes using node.js so simple it is mind boggling… Without going into masses of detail on node.js (which I might at some point) here is the simple example of what I am trying to do and why npm is so cool. Node Package Manager (npm) allows you to install any node [read] Keywords: application applications interface
760


Create your own Watson Q and A example with Bluemix, Webstorm and Jazz Hub
Sun, Oct 12th 2014 10:19p   Mark Roden
Introduction In this article I will demonstrate how to get up and running with one of the Bluemix/Watson service examples. I will be using the example provided by IBM in their documentation as the basis for the article but the way in which I achieved the final goal was quite different from the way that they explained it in the example. This example will use: IBM Bluemix as my service provider The Watson Question and Answer service A Node.js service to host the website JetBrains Webstorm IDE [read] Keywords: domino ibm application css integration javascript password server
268


Getting into IBM Bluemix….this could be interesting
Wed, Oct 8th 2014 7:12p   Mark Roden
My interest in IBM Bluemix has grown since it was announced. I took part in the Beta, but frankly didn’t do very much because I really couldn’t figure out what it was or why I cared. Since then though IBM has announced that they are investigating putting Domino into Bluemix. Before I start down this path I have to say at this point that I have no idea what “Domino in Bluemix” even means. I have no idea what that will look like and while I would love to second guess a [read] Keywords: domino ibm xpages application applications development interface java mobile server




199


Opening an XPage in XPiNC and passing Query_String parameters
Tue, Sep 30th 2014 7:22p   Mark Roden
I was very pleasantly surprised to find this works – coincidentally – twice this week someone has asked this question – can I open an XPage in XPiNC directly? I thought the answer was no……and not for the first (and/or last) time I was wrong. The answer lies here – http://www-10.lotus.com/ldd/ddwiki.nsf/dx/Domino_Designer_URLs_for_XPages To prove it I created a plain XPage and added the firebugLite custom control The following XPiNC URL notes://copper/882579C [read] Keywords: ldd lotus notes
271


Closing soon: IBM Domino/Notes Community Survey
Mon, Sep 29th 2014 11:12a   Mark Roden
For the last two weeks PSC has been asking for input from the ICS community on what companies are planning on doing with their Domino Infrastructure. If you have not already done so, please take a couple of minutes to help. The results will be posted next week. http://bit.ly/PSCXPagesSurvey [read] Keywords: domino dominonotes ibm notes community
236


What is a social presence worth?
Sun, Sep 21st 2014 7:51p   Mark Roden
We had an interesting discussion internally at work about what exactly does our “Social Presence” do for us? I put time and thought to it and it turns out to be a question I can answer on many levels. I am still not entirely sure what the answer is. What does being social mean? Being social means sharing through ideas, code, concepts, dreams….anything really – but sharing it. Within the XPages community we have a multitude of people who are social for many different r [read] Keywords: domino ibm xpages community development java office sharepoint
557


Running an XPages/Angular.js application on a Bluemix site
Wed, Sep 17th 2014 7:48p   Mark Roden
In this article I will show you how to run an XPages application based on Angular data within a Bluemix based website. Introduction For background reading on this article please review my series on Angular.js in XPages starting here. I will be using the application described within that article as the starting point for this article. A little background on Bluemix Bluemix is IBM’s new Platform as a Service (PaaS) system which provides the end to end cloud based hosting of application [read] Keywords: domino ibm xpages application applications bug community database interface server skype




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