Tuesday, November 24, 2009

Alfresco Share - helloworld Dashlet

In this blog entry, I will creare a simple HelloWorld(most favorite for all) dashlet in Alfresco Share.

Dashlet is simple component, which makes together dashboard. Dashlet is single Web Script.

To create a dashlet, we need following files from that some files are optional, you may not require in each and every dashlet.

Create all files in the following folder (As per your installation)
C:\Alfresco3.1.2\tomcat\webapps\share\WEB-INF\classes\alfresco\site-webscripts\org\alfresco\components\dashlets

helloworld.get.desc.xml
helloworld.get.js
helloworld.get.html.ftl
helloworld.get.properties

helloworld.get.desc.xml

This is description file of our dashlet which includes display name, description, where you want to put your dashlet, either in user-dashlet family or in site-dashlet family, and url of dashlet. It may include other basics like required authentication, transaction is required or not etc.

<webscript>
   <shortname>Hello World</shortname>
   <description>Hello World Dashlet</description>
   <family>user-dashlet</family>
   <url>/components/dashlets/hello-world</url>
</webscript>


helloworld.get.js

Java script file is to add behavior in the dashlet. It can be used to interact back-end  store. It is optional.
Here, we do not require java script file, but I will show how we can use it.

var name = "niketa";
model.user = name;


helloworld.get.properties

This is our property file, It is also optional

title = Hello World

helloworld.get.html.ftl

This is a freemarker template file. It will render the response.

<div class="dashlet">
  <div class="title">${msg("title")}</div><#-- title’s value will be taken from property file - ->        
  <div class="body scrollableList">
    Hello ${user} <#-- user’s value will be taken from .js file - ->         
  </div>
</div>


To test the dashlet
Go to http://localhost:8080/share/service/index

Click on Refresh Web Scripts

If everything is fine then it will give you following message with number of web script. (Which obviously may differ)

"Maintenance Completed
Reset Web Scripts Registry; registered 179 Web Scripts. Previously, there were 178 "

Login in to your Share (http://localhost:8080/share/)

Click on Customize the dashboard,  ( Add Dashlet,
Here you should find our new dashlet named - Hello World, Add it

And on your dashboard, you will find the message "Hello niketa"

8 comments:

  1. This is really nice post for freshers who are working on alfresco share at the first time

    ReplyDelete
  2. Nice post, got me started. Thanks.

    ReplyDelete
  3. I did all this, but the message Hello ${user} is not getting displayed.....

    ReplyDelete
  4. I am not getting the message Hello ${user} in the dashlet..

    ReplyDelete
  5. I also don't get any message.

    Also, the layout of my homepage gets messed up - all the dashlets, including Hello World, now appear in one column, although when I click "Customize Dashboard", Alfresco still thinks I have them spread over a two column layout.

    ReplyDelete
  6. The post it's ok. Just remove the comments <#-- --> :)

    ReplyDelete
  7. YAAA ITS WORKING FINE ... JUST REMOVE COMMENTS IN FTL FILE

    ReplyDelete
  8. How to modify MyDocuments Dashlet with advance features..can any one help me please

    ReplyDelete