Making a Dashlet work in Alfresco Share

Go to this folder : (this is where my tomcat/alfresco3.4.4 is installed)


Add three files :


   <description>MJB's test Dashlet</description>


<div class="dashlet">
   <div class="title">${title}</div>
   <div class="body">
	<div> cmisQuery       = ${cmisQuery!""} </div>
	<div> Aantal entries  = ${no_entries!""} </div>
   	<div> props[icon]     = ${props["icon"]!""} </div>
      	<div> props[propName] = ${props["propName"]!""} </div>
	<div> doc             = ${doc!""} </div>
	<div> object          = ${object!""} </div>
	<div> properties      = ${properties!""} </div>
	<div> Qname           = ${Qname!""} </div>
	<div> propName        = ${text!""} </div>
	<div> name	      = ${name!""} </div>


// Needs to come from cmis:document because cmis:file returns nothing
var selectString =  "SELECT d.*, t.*, a.* FROM cmis:document AS d " +
		    "JOIN cm:titled AS t ON d.cmis:objectId = t.cmis:objectId " +
		    "JOIN cm:author AS a ON d.cmis:objectId = a.cmis:objectId " +
		    "WHERE IN_FOLDER(d, 'workspace://SpacesStore/560b8dd6-6503-4ad5-8066-5946c1456ec1') " +
		    "ORDER BY d.cmis:name"

var cmisQuery = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\" ?><cmis:query xmlns:cmis=\"\"><cmis:statement>" + selectString + "</cmis:statement></cmis:query>";

// get the documents for the currently active site
var conn = remote.connect("alfresco");

var result ="/cmis/queries"), cmisQuery, "application/cmisquery+xml");

	if (result != null) {model.title = "ik krijg iets terug van de query";} else { model.title = "ik krijg niets terug van de query"; }
	model.title = "resultset from query";	// Titel voor de dashlet
	model.result = result;					// keihard de XML -als ruw block data- overgooien.
	model.cmisQuery = cmisQuery;			// Query weergeven

// Lets make a proof of the pudding model.

function getElementByTagName(list, elTagName) {
   var el;
   for (var i = 0, l = list.size(); i < l; i++) {
      el = list.get(i);
      if (el.QName.localPart == elTagName) {
	 model.Qname = el;
         return el;
   return null;

function createModel(feed) {
  var list = new Array();
  var entries = feed.getEntries();
  model.entries = entries;
  model.no_entries = entries.size();

  for (var i=0; i < entries.size(); i++) {
    var doc = entries.get(i);
        model.doc = doc;
    var object =  doc.getExtension(atom.createQName("","object"));
    model.object = object;
	properties = getElementByTagName(object.getElements(), "properties"); = properties;
    propertiesList = properties.getElements();
	var props = new Array();
	props["icon"] = doc.getExtension(atom.createQName("","icon")).getText();

	model.text = "";
	var mjb = true;

    for (var j = 0; j < propertiesList.size(); j++) {
      property = propertiesList.get(j);
      if (property != null && property.firstChild != null) {
		 model.text += property.getAttributeValue("propertyDefinitionId");

		 if ((property.getAttributeValue("propertyDefinitionId") == "cmis:name") && (mjb = true)) {
			mjb = false;
			//found cmis:name = property.firstChild.text;
		 var propName = localPart(property.getAttributeValue("propertyDefinitionId"));
		 props[propName] = property.firstChild.text;
		 model.propName = propName;
	model.props = props;
	list[i] = props;
  return list;

function localPart(qName){
  return qName.substring(qName.lastIndexOf(":") + 1, qName.length());

Note that the workspace ID works for me – but will not work for you. You will need to replace this : workspace://SpacesStore/560b8dd6-6503-4ad5-8066-5946c1456ec1
with a noderef to a directory with a files in it.

Get your own noderef by going into Alfresco – find  a nice looking directory – go to “View Details” – find the Alfresco Node Reference link – right-click and “Copy link adress” which has a similar format (workspace://SpacesStore/some-numbers-and-letters-with-dashes) Paste this is the javascript file (mjb.get.js)

Once the files are in place, your need to update the Alfresco Share webscripts library:
Press the refresh button – you should see 1 more webscript available.
Then login to share
Click ‘dashboard wijzigen’ and drag your new dashlet (called MJB) into it.

Yes I know it is very dirty code. It’s even throwing horrible looking output.
But it’s just a small proof of the pudding that shows it’s working.


Geef een reactie

Vul je gegevens in of klik op een icoon om in te loggen. logo

Je reageert onder je account. Log uit /  Bijwerken )

Google+ photo

Je reageert onder je Google+ account. Log uit /  Bijwerken )


Je reageert onder je Twitter account. Log uit /  Bijwerken )

Facebook foto

Je reageert onder je Facebook account. Log uit /  Bijwerken )


Verbinden met %s