{"id":37769,"date":"2015-04-21T05:55:49","date_gmt":"2015-04-21T12:55:49","guid":{"rendered":"http:\/\/localhost\/exoblog\/?p=8692"},"modified":"2015-04-21T05:55:49","modified_gmt":"2015-04-21T12:55:49","slug":"building-an-auto-image-slideshow-using-ajax-dom-object-with-exo-driverconnector-api","status":"publish","type":"post","link":"https:\/\/www.exoplatform.com\/blog\/building-an-auto-image-slideshow-using-ajax-dom-object-with-exo-driverconnector-api\/","title":{"rendered":"Building an auto image slideshow using AJAX &amp; DOM Object with eXo DriverConnector API"},"content":{"rendered":"<p><a href=\"https:\/\/www.exoplatform.com\/blog\/building-an-auto-image-slideshow-using-ajax-dom-object-with-exo-driverconnector-api\/\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-full wp-image-8700\" src=\"https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2015\/04\/Image-slideshow.jpg\" alt=\"Image-slideshow\" width=\"650\" height=\"220\" srcset=\"https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2015\/04\/Image-slideshow.jpg 650w, https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2015\/04\/Image-slideshow-300x102.jpg 300w, https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2015\/04\/Image-slideshow-500x169.jpg 500w, https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2015\/04\/Image-slideshow-360x122.jpg 360w, https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2015\/04\/Image-slideshow-200x68.jpg 200w, https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2015\/04\/Image-slideshow-100x34.jpg 100w, https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2015\/04\/Image-slideshow-70x24.jpg 70w\" sizes=\"(max-width: 650px) 100vw, 650px\" \/><\/a><\/p>\n<p>AJAX allows a gadget to be updated asynchronously by exchanging small amounts of data with the server behind the scenes. Moreover, with the support of HTML DOM Object, the gadget\u2019s content can be created dynamically based on AJAX\u2019s response data. This section shows you how to leverage these utilities to customize your gadget.<br \/>\n<!--more--><br \/>\n1\/ Create a basic <span class=\"navCode\">pom.xml<\/span> file and configure your gadget\u2019s name as <em>auto-slideshow<\/em> as follows:<\/p>\n<pre class=\"lang:default decode:true\">&lt;project xmlns=\"https:\/\/maven.apache.org\/POM\/4.0.0\" xmlns:xsi=\"https:\/\/www.w3.org\/2001\/XMLSchemainstance\"\nxsi:schemaLocation=\"https:\/\/maven.apache.org\/POM\/4.0.0 https:\/\/maven.apache.org\/maven-v4_0_0.xsd\"&gt;\n&nbsp;&nbsp; &nbsp;&lt;modelVersion&gt;4.0.0&lt;\/modelVersion&gt;\n&nbsp;&nbsp; &nbsp;&lt;groupId&gt;sample&lt;\/groupId&gt;\n&nbsp;&nbsp; &nbsp;&lt;artifactId&gt;gadget&lt;\/artifactId&gt;\n&nbsp;&nbsp; &nbsp;&lt;packaging&gt;war&lt;\/packaging&gt;\n&nbsp;&nbsp; &nbsp;&lt;version&gt;1.0&lt;\/version&gt;\n&nbsp;&nbsp; &nbsp;&lt;name&gt;Auto Slideshow Gadget sample&lt;\/name&gt;\n&nbsp;&nbsp; &nbsp;&lt;build&gt;\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;finalName&gt;auto-slideshow&lt;\/finalName&gt;\n&nbsp;&nbsp; &nbsp;&lt;\/build&gt;\n&lt;\/project&gt;<\/pre>\n<p>2\/ Add this <span class=\"navCode\">web.xml<\/span> file to the <span class=\"navCode\">src\/main\/webapp\/WEB-INF<\/span> directory of your project:<\/p>\n<pre class=\"lang:default decode:true\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?&gt;\n&lt;web-app version=\"3.0\" metadata-complete=\"true\"\nxmlns=\"https:\/\/java.sun.com\/xml\/ns\/javaee\" xmlns:xsi=\"https:\/\/www.w3.org\/2001\/XMLSchema-instance\"\nxsi:schemaLocation=\"https:\/\/java.sun.com\/xml\/ns\/javaee https:\/\/java.sun.com\/xml\/ns\/javaee\/web-app_3_0.xsd\"&gt;\n&nbsp;&nbsp; &nbsp;&lt;display-name&gt;auto-slideshow&lt;\/display-name&gt;\n&lt;\/web-app&gt;<\/pre>\n<p>3\/ Now, create a simple UI for your gadget with its style:<\/p>\n<pre class=\"lang:default decode:true\">&lt;!--Defining style for gadget--&gt;\n&nbsp; &lt;style type=\"text\/css\"&gt;\n&nbsp;&nbsp; &nbsp;img {\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;width: 240px;\n&nbsp;&nbsp; &nbsp;}\n&nbsp;&nbsp; &nbsp;#slideshow { \n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;margin: 10px auto 10px; \n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;position: relative; \n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;width: 240px; \n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;height: 200px; \n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;padding: 10px; \n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;box-shadow: 0 0 20px rgba(0,0,0,0.4); \n&nbsp;&nbsp; &nbsp;}\n&nbsp;&nbsp; &nbsp;#slideshow &gt; div { \n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;position: absolute; \n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;top: 10px; \n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;left: 10px; \n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;right: 10px; \n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;bottom: 10px; \n&nbsp;&nbsp; &nbsp;}\n&nbsp; &lt;\/style&gt;\n&nbsp; \n&nbsp; &lt;!--Gadget's main body which will be added by HTML DOM Object later--&gt;\n&nbsp; &lt;div id=\"slideshow\"&gt;\n&nbsp; &lt;\/div&gt;<\/pre>\n<p>4\/ Create the following JavaScript function using AJAX to call the DriverConnector API to get all the public images of the root user (see <a href=\"https:\/\/docs-old.exoplatform.org\/public\/index.jsp?topic=%2FPLF43%2FPLFAdminGuide.Database.ConfiguringPLF.html\" target=\"_blank\" rel=\"noopener\">here<\/a> for more details). Notice the <span class=\"navCode\">traverseXMLDoc<\/span> function will be created in the following steps.<\/p>\n<pre class=\"lang:default decode:true\">function getImages() {\n&nbsp;&nbsp; &nbsp;\/\/This function uses AJAX to send GET request to server's DriverConnector API and receive XML response\n&nbsp;&nbsp;&nbsp;&nbsp; jQuery.ajax({\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; type: \"GET\",\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; url: \"https:\/\/localhost:8080\/portal\/rest\/wcmDriver\/getFoldersAndFiles?driverName=Collaboration&amp;currentFolder=Users\/r___\/ro___\/roo___\/root\/Private\/Pictures&amp;currentPortal=intranet&amp;repositoryName=repository&amp;workspaceName=collaboration&amp;filterBy=Image\",\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; contentType: \"application\/xml; charset=utf-8\",\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dataType: \"xml\",\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; success: function (data, status, jqXHR) {\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;var strResults=new XMLSerializer().serializeToString(data.documentElement);\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;\/\/build dynamic html content for \"slideshow\" div tag\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;traverseXMLDoc(strResults, \"slideshow\");\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; },\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;\/\/error report\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; error: function (jqXHR, status) {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/\/ error handler\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; alert(\"Cannot retrieve data!\");\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }\n&nbsp;&nbsp; &nbsp;});\n&nbsp;&nbsp; &nbsp;}<\/pre>\n<p>5\/ Create the <span class=\"navCode\">traverseXMLDoc<\/span> function with two input parameters as follows:<\/p>\n<pre class=\"lang:default decode:true\">function traverseXMLDoc(xmlDoc, idOfContainerDomElement){\n&nbsp;&nbsp; &nbsp;\/\/This function traverses through the whole XML response returned from server\n&nbsp;&nbsp; &nbsp;\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;var $xmlDocObjChildren, $contentDiv;\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;$contentDiv = $('#' + idOfContainerDomElement);\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if ($contentDiv.length === 0) {\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;throw new Error('There are no DOM elements with this id: \"' + idOfContainerDomElement + '\"');\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;\/\/Information of each image object is contained in \"File\" tag\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;$xmlDocObjChildren = $(xmlDoc).find(\"File\");\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;$xmlDocObjChildren.each(function(index, Element) {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var $currentObject = $(this),\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; childElementCount = Element.childElementCount,\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;\/\/Image's url is contained in \"url\" attribute\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; currentNodeType = $currentObject.attr('url');\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;\/\/Adding dynamic content into gadget's body\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $contentDiv.append('&lt;div&gt;&lt;img src=\"'+currentNodeType+'\"&gt;&lt;\/div&gt;');\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;});\n&nbsp;&nbsp; &nbsp;}<\/pre>\n<p>6\/ Now, add some image effects to your gadget:<\/p>\n<pre class=\"lang:default decode:true\">&lt;script type=\"text\/javascript\"&gt;\n\/\/Creating gagdet's effects\n&nbsp;&nbsp; &nbsp;$(\"#slideshow &gt; div:gt(0)\").hide();\n&nbsp;&nbsp; &nbsp;setInterval(function() { \n&nbsp;&nbsp; &nbsp;&nbsp; $('#slideshow &gt; div:first')\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;.fadeOut(1000)\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;.next()\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;.fadeIn(1000)\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;.end()\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;.appendTo('#slideshow');\n&nbsp;&nbsp; &nbsp;},&nbsp; 3000);\n &lt;\/script&gt;<\/pre>\n<p>7\/ Finally, include all your created contents in the <span class=\"navCode\">AutoSlideshowGadget.xml<\/span> file under <span class=\"navCode\">src\/main\/webapp\/gadgets\/AutoSlideshowGadget\/<\/span> to get this script:<\/p>\n<pre class=\"lang:default decode:true\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\" ?&gt;\n&lt;Module&gt;\n&nbsp; &lt;ModulePrefs title=\"Memories!\" width=\"240\" height=\"200\"\/&gt;\n&nbsp; &lt;Content type=\"html\"&gt;\n&nbsp; &lt;![CDATA[\n&nbsp; &lt;!--Including JQuery library--&gt;\n&nbsp; &lt;script src=\"https:\/\/code.jquery.com\/jquery-2.1.3.js\"&gt;&lt;\/script&gt;\n&nbsp; \n&nbsp; &lt;!--Defining style for gadget--&gt;\n&nbsp; &lt;style type=\"text\/css\"&gt;\n&nbsp;&nbsp; &nbsp;img {\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;width: 240px;\n&nbsp;&nbsp; &nbsp;}\n&nbsp;&nbsp; &nbsp;#slideshow { \n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;margin: 10px auto 10px; \n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;position: relative; \n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;width: 240px; \n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;height: 200px; \n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;padding: 10px; \n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;box-shadow: 0 0 20px rgba(0,0,0,0.4); \n&nbsp;&nbsp; &nbsp;}\n&nbsp;&nbsp; &nbsp;#slideshow &gt; div { \n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;position: absolute; \n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;top: 10px; \n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;left: 10px; \n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;right: 10px; \n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;bottom: 10px; \n&nbsp;&nbsp; &nbsp;}\n&nbsp; &lt;\/style&gt;\n&nbsp; \n&nbsp; &lt;!--Gadget's main body which will be added by HTML DOM Object later--&gt;\n&nbsp; &lt;div id=\"slideshow\"&gt;\n&nbsp; &lt;\/div&gt;\n&nbsp; \n&nbsp; &lt;script type=\"text\/javascript\"&gt;\n&nbsp;&nbsp;&nbsp; getImages();\n&nbsp;&nbsp; &nbsp;function traverseXMLDoc(xmlDoc, idOfContainerDomElement){\n&nbsp;&nbsp; &nbsp;\/\/This function traverses through the whole XML response returned from server\n&nbsp;&nbsp; &nbsp;\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;var $xmlDocObjChildren, $contentDiv;\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;$contentDiv = $('#' + idOfContainerDomElement);\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if ($contentDiv.length === 0) {\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;throw new Error('There are no DOM elements with this id: \"' + idOfContainerDomElement + '\"');\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;\/\/Information of each image object is contained in \"File\" tag\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;$xmlDocObjChildren = $(xmlDoc).find(\"File\");\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;$xmlDocObjChildren.each(function(index, Element) {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; var $currentObject = $(this),\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; childElementCount = Element.childElementCount,\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;\/\/Image's url is contained in \"url\" attribute\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; currentNodeType = $currentObject.attr('url');\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;\/\/Adding dynamic content into gadget's body\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $contentDiv.append('&lt;div&gt;&lt;img src=\"'+currentNodeType+'\"&gt;&lt;\/div&gt;');\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;});\n&nbsp;&nbsp; &nbsp;}\n&nbsp;&nbsp; &nbsp;\n&nbsp;&nbsp; &nbsp;function getImages() {\n&nbsp;&nbsp; &nbsp;\/\/This function uses AJAX to send GET request to server's DriverConnector API and receive XML response\n&nbsp;&nbsp;&nbsp;&nbsp; jQuery.ajax({\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; type: \"GET\",\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; url: \"https:\/\/localhost:8080\/portal\/rest\/wcmDriver\/getFoldersAndFiles?driverName=Collaboration&amp;currentFolder=Users\/r___\/ro___\/roo___\/root\/Private\/Pictures&amp;currentPortal=intranet&amp;repositoryName=repository&amp;workspaceName=collaboration&amp;filterBy=Image\",\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; contentType: \"application\/xml; charset=utf-8\",\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; dataType: \"xml\",\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; success: function (data, status, jqXHR) {\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;var strResults=new XMLSerializer().serializeToString(data.documentElement);\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;\/\/build dynamic html content for \"slideshow\" div tag\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;traverseXMLDoc(strResults, \"slideshow\");\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; },\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;\/\/error report\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; error: function (jqXHR, status) {\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \/\/ error handler\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp; alert(\"Cannot retrieve data!\");\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }\n&nbsp;&nbsp; &nbsp;});\n&nbsp;&nbsp; &nbsp;}\n&nbsp;&nbsp; &nbsp;\n&nbsp;&nbsp; &nbsp;\/\/Creating gagdet's effects\n&nbsp;&nbsp; &nbsp;$(\"#slideshow &gt; div:gt(0)\").hide();\n&nbsp;&nbsp; &nbsp;setInterval(function() { \n&nbsp;&nbsp; &nbsp;&nbsp; $('#slideshow &gt; div:first')\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;.fadeOut(1000)\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;.next()\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;.fadeIn(1000)\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;.end()\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;.appendTo('#slideshow');\n&nbsp;&nbsp; &nbsp;},&nbsp; 3000);\n&nbsp; &lt;\/script&gt;\n&nbsp; ]]&gt;\n&nbsp; &lt;\/Content&gt;\n&lt;\/Module&gt;<\/pre>\n<p>Notice that you can follow <a href=\"https:\/\/docs-old.exoplatform.org\/public\/index.jsp?topic=%2FPLF42%2FPLFDevGuide.DevelopingApplications.DevelopingGadget.CreatingGadget.html\" target=\"_blank\" rel=\"noopener\">this<\/a> to create CSS and JavaScript resources in separate files to share with other gadgets. In this guide, we keep it simple by including one file only.<\/p>\n<p>8\/ Add the following content to the <span class=\"navCode\">gadget.xml<\/span> file under the <span class=\"navCode\">src\/main\/webapp\/WEB-INF<\/span> directory:<\/p>\n<pre class=\"lang:default decode:true  \">&lt;gadgets\nxmlns:xsi=\"https:\/\/www.w3.org\/2001\/XMLSchema-instance\"\nxsi:schemaLocation=\"https:\/\/www.gatein.org\/xml\/ns\/gatein_objects_1_0 https:\/\/www.gatein.org\/xml\/ns\/gadgets_1_0\"\nxmlns=\"https:\/\/www.gatein.org\/xml\/ns\/gadgets_1_0\"&gt;\n&nbsp;&nbsp; &nbsp;&lt;gadget name=\"AutoSlideshowGadget\"&gt;\n&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&lt;path&gt;\/gadgets\/AutoSlideshowGadget\/AutoSlideshowGadget.xml&lt;\/path&gt;\n&nbsp;&nbsp; &nbsp;&lt;\/gadget&gt;\n&lt;\/gadgets&gt;<\/pre>\n<p>9\/ Create the target war with the Maven command: <span class=\"navCode\">mvn clean install<\/span><\/p>\n<p>10\/ Add the context name <em>auto-slideshow<\/em> of the gadget war to <span class=\"navCode\">$PLATFORM_TOMCAT_HOME\/lib\/customextension-config.jar!\/conf\/configuration.xml<\/span> as in step 6 of <a href=\"https:\/\/docs.exoplatform.org\/en\/5.2\/Application.html\" class=\"broken_link\" target=\"_blank\" rel=\"noopener\">Create a very simple gadget<\/a>.<\/p>\n<p>11\/ Restart the server, then deploy it in the application server by copying the generated web archive <span class=\"navCode\">autoslideshow.war<\/span>, from the target folder into the deployment folder where you unpacked the eXo Platform installation.<\/p>\n<p>12\/ Go to the <strong>Applications<\/strong> menu and select the <strong>Gadget<\/strong> button. The new gadget will be listed:<\/p>\n<p><a href=\"https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2015\/04\/01-gadget-details.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-8696\" src=\"https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2015\/04\/01-gadget-details.png\" alt=\"01-gadget-details\" width=\"650\" srcset=\"https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2015\/04\/01-gadget-details.png 1064w, https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2015\/04\/01-gadget-details-300x129.png 300w, https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2015\/04\/01-gadget-details-1024x442.png 1024w, https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2015\/04\/01-gadget-details-768x331.png 768w, https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2015\/04\/01-gadget-details-720x311.png 720w, https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2015\/04\/01-gadget-details-500x216.png 500w, https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2015\/04\/01-gadget-details-360x155.png 360w, https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2015\/04\/01-gadget-details-200x86.png 200w, https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2015\/04\/01-gadget-details-100x43.png 100w, https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2015\/04\/01-gadget-details-70x30.png 70w\" sizes=\"(max-width: 1064px) 100vw, 1064px\" \/><\/a><\/p>\n<p>Add this gadget into a specific category to bring it into use.<\/p>\n<p>13\/ Before using this gadget, you need to log in as root user. Then you can upload images into the <span class=\"navCode\">Pictures<\/span> folder under the <span class=\"navCode\">Documents<\/span> folder.<\/p>\n<p>14\/ Go to the <strong>Dashboard<\/strong> to insert the gadget into the page. Open the <strong>Dashboard Workspace<\/strong> by clicking the <strong>Add Gadgets<\/strong> link and choose the auto slideshow gadget named \u201c<em>Memories!<\/em>\u201d The result is as below:<\/p>\n<p><a href=\"https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2015\/04\/02-gadget.png\"><img decoding=\"async\" loading=\"lazy\" class=\"aligncenter size-medium wp-image-8697\" src=\"https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2015\/04\/02-gadget.png\" alt=\"02-gadget\" width=\"648\" height=\"474\" srcset=\"https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2015\/04\/02-gadget.png 648w, https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2015\/04\/02-gadget-300x219.png 300w, https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2015\/04\/02-gadget-448x328.png 448w, https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2015\/04\/02-gadget-323x236.png 323w, https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2015\/04\/02-gadget-179x131.png 179w, https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2015\/04\/02-gadget-100x73.png 100w, https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2015\/04\/02-gadget-41x30.png 41w\" sizes=\"(max-width: 648px) 100vw, 648px\" \/><\/a><\/p>\n<p>The source code for this demonstration is <a href=\"https:\/\/github.com\/lannt-exoer\/exo-gadget-auto-slideshow\" target=\"_blank\" rel=\"noopener\">available on GitHub<\/a>, so you can download and test it.<\/p>\n<p>(this article was originally posted on my blog: <a href=\"https:\/\/lanbk52.wordpress.com\/2015\/04\/18\/building-an-auto-image-slideshow-using-ajaxdom-object-with-exo-driverconnector-api\/\" target=\"_blank\" rel=\"noopener\" class=\"broken_link\">Lan Nguyen ~ Writing is sharing<\/a>)<\/p>\n<p><b><a href=\"https:\/\/community.exoplatform.com\/portal\/dw\/\" target=\"_blank\" rel=\"noopener\">Join the eXo tribe<\/a> by registering for the community and get updates, tutorials, support, and access to the Platform and add-on downloads!<\/b><\/p>\n<p><!--begin adv-events--><\/p>\n<div class=\"adv-events\" style=\"background: #476fad;padding: 30px 20px;color: white\">\n<div class=\"media\">\n<div class=\"pull-right\"><a href=\"https:\/\/www.exoplatform.com\/contact-us\/?utm_source=BlogEn&amp;utm_medium=Blog&amp;utm_campaign=Content&amp;utm_content=cta\"><br \/>\n<img decoding=\"async\" loading=\"lazy\" class=\"size-full wp-image-6587 alignright\" src=\"https:\/\/www.exoplatform.com\/blog\/wp-content\/uploads\/2014\/02\/how-to-make-the-most-of-eXo-platform41.png\" alt=\"make-the-most-out-of-eXo-platform4\" width=\"161\" height=\"85\"><br \/>\n<\/a><\/div>\n<div class=\"media-body\">\n<h4 class=\"media-heading\">Make the most out of eXo Platform 4<\/h4>\n<p>Register to the next weekly live demo session and get a complete overview of what you can do with eXo Platform 4. <strong><a href=\"https:\/\/www.exoplatform.com\/contact-us\/?utm_source=BlogEn&amp;utm_medium=Blog&amp;utm_campaign=Content&amp;utm_content=link\">Reserve your seat now!<\/a><\/strong><\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!--end adv-events--><\/p>\n","protected":false},"excerpt":{"rendered":"AJAX allows a gadget to be updated asynchronously by exchanging small amounts of data with the server behind the scenes. Moreover, with the support of HTML DOM Object, the gadget\u2019s content can be created dynamically based on AJAX\u2019s response data. This section shows you how to leverage these utilities to customize your gadget.","protected":false},"author":105,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[699],"tags":[],"lang":"en","translations":{"en":37769},"pll_sync_post":[],"_links":{"self":[{"href":"https:\/\/www.exoplatform.com\/blog\/wp-json\/wp\/v2\/posts\/37769"}],"collection":[{"href":"https:\/\/www.exoplatform.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.exoplatform.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.exoplatform.com\/blog\/wp-json\/wp\/v2\/users\/105"}],"replies":[{"embeddable":true,"href":"https:\/\/www.exoplatform.com\/blog\/wp-json\/wp\/v2\/comments?post=37769"}],"version-history":[{"count":0,"href":"https:\/\/www.exoplatform.com\/blog\/wp-json\/wp\/v2\/posts\/37769\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.exoplatform.com\/blog\/wp-json\/wp\/v2\/media?parent=37769"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.exoplatform.com\/blog\/wp-json\/wp\/v2\/categories?post=37769"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.exoplatform.com\/blog\/wp-json\/wp\/v2\/tags?post=37769"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}