|Extension Point||Surf Dashlets (It is recommended to use Aikau Dashlets instead)|
|Architecture Information||Share Architecture.|
The following picture shows a User Dashboard with a number of Dashlets, such as My Sites and My Tasks:
You can implement your own custom Dashlets that can be added to either the User Dashboard or the Site Dashboard.Creating a Surf Dashlet is the same thing as creating a Surf Web Script. Before continuing read through the Surf Web Scripts section.
The controller of the Dashlet Presentation Web Script will usually call a Data Web Script on the Alfresco Repository side to get the content that should be displayed in the Dashlet.
Let's look at an example of a custom Dashlet, the following picture shows a Member Directory Dashlet that can be used to search the User/People directory:
This Dashlet is implemented using a Presentation Web Script, which in turn uses a Data Web Script to get the people matching the Search Filter parameter. The following picture illustrates:
In this case we have a Spring Surf Web Script on the Share side that will, in its controller, call a Repository Web Script (i.e. Data Web Script) to get a list of person records in JSON format. The controller looks something like this:
// Get args from the Share page URL var filterValue = page.url.args["filter"]; var connector = remote.connect("alfresco"); var peopleJSONString = connector.get("/api/people?filter=" + filterValue); // create json object from data var peopleJSON = jsonUtils.toObject(peopleJSONString); model.people = peopleJSON["people"];
The controller makes use of a special root object called remote, which is used to connect to a remote service, such as the Alfresco Repository, and get data. The JSON data is returned from a Repository Web Script (i.e. Data Web Script), which in its controller uses Alfresco's public API to fetch person information matching passed in Search Filter (i.e. filter).
The Repository Web Script uses a root object called people to search for person info. This root object is Alfresco specific and is only available in Repository Web Scripts.
Now, to create a Dashlet Web Script you also need a descriptor, which is defined in XML and looks something like this:
<webscript> <shortname>Member Directory</shortname> <description>Provide Search of people and display in a list</description> <family>user-dashlet</family> <url>/components/dashlets/member-directory</url> </webscript>
The descriptor looks like any other Web Script descriptor except the family parameter, which can have the following values:
The Dashlet UI needs to be implemented in the Web Script template as follows:
member.directory.dashletName=Member Directory member.directory.searchFilter=Search Filter member.directory.searchResult=Search Result
|Deployment - App Server||
Best practice is to put the files in a directory that explains what they are for, such as for example:
|Deployment - SDK Project||
|Alfresco Developer Blogs|