Sunday, February 21, 2016

[Analytics Dashboards] XML Structure of a gadget

We can create our own dashboards in WSO2 Dashboard Designer in DAS. These dashboards contains gadgets. There are some samples in WSO2 Dashboard Designer. But we can create our own custom gadgets and then we can add them to our own dashboard.
When we create a gadget we need to create a XML file. This XML file come up with a common format. In this blog post I am going to introduce about this common format.



As shown in above diagram this XML file is wrapped with <Module> tag and inside it there are three sections as Gadget Preferences , User Preferences and Content Section.

<?xml version="1.0" encoding="UTF-8" ?>

This is the first line of any gadget which is used to indicate the format of the document.
In this case it indicates this document  uses XML format with UTF-8 character encoding.

<module>

This node is use to wrap gadget preferences,user preferences and content section of the gadget.

<ModulePrefs>

This section is used to keep the meta data of the gadget such as title,author,description etc. And also we can define the dimensions of the gadget such as height,width etc under this section.

Ex :

<ModulePrefs title="Bar Chart"
author="WSO2 DAS Server"
height="230"
scrolling="true"
description="A generic Bar Chart gadget, that display patch-count Vs Month.">
</ModulePrefs>

<UserPrefs>

Under this section you can store your own configuration values and allow users to give inputs for the application. This part is an optional thing.

Ex :

<UserPref name="dataSource"
display_name="Data Source"
default_value="/portal/gadgets/bar-chart/datasource/dataFile4.jag">
</UserPref>

<Content>

Under this section you can write your own code of the gadget implementation such as HTML,Javascript,CSS etc.

Ex : If we use HTML then the content is defined as shown below.

<Content type="html">
<![CDATA[
<html>
<head>
</head>
<body >
</body>
</html>
]]>
</Content>

 

1 comment: