cancel
Showing results for 
Search instead for 
Did you mean: 

trying to create hellouser dashlet script that retrieve from alfresco repository

hdalang
Champ in-the-making
Champ in-the-making
I'm trying to print "hello admin" in the dashlet, that retrieve from alfresco repository. I'm using alfresco 4.2.f.
What I see in my dashlet is a message like this:

Hello
org.mozilla.javascript.Undefined@6c251a4c

also I have attached the figure with this message, if you want to see.
I want to know where's my mistake.

I'll paste first the alfresco repository code:
1-hellouser.get.desc.xml

<webscript>
<shortname>Hello User</shortname>
<description>Personalized greeting</description>
<url>/hellouser</url>
<authentication>user</authentication>
<negotiate accept="text/html">html</negotiate>
<negotiate accept="application/json">json</negotiate>
</webscript>


2-hellouser.get.json.ftl

{greeting: "hello", user: "${person.properties.userName}"}


3-hellouser.get.html.ftl

Hello ${person.properties.userName}


and the share code is as following:
1-hellouser.get.html.ftl

<div class="dashlet">
  <div class="title">Hello </div>
  <div class="body scrollableList">
    ${hellouser} <#– user’s value will be taken from .js file –>
  </div>
</div>


2-hellouser.get.js

function main()

{
var connector = remote.connect("alfresco");
var data = connector.get("/hellouser.json");

// create json object from data
var result = eval('(' + data + ')');
model.hellouser = result["hellouser"];
}

main();


hellouser.get.desc.xml

<webscript>
   <shortname>Hello World</shortname>
   <description>Hello World Dashlet</description>
   <family>dashlet</family>
   <url>/components/dashlets/hellouser</url>
</webscript>
4 REPLIES 4

douglascrp
World-Class Innovator
World-Class Innovator
In the fiel "2-hellouser.get.js"

Change it to this:


function main()
{
    var connector = remote.connect("alfresco");
    var data = connector.get("/hellouser.json");

    // create json object from data
    var result = eval('(' + data + ')');
    model.hellouser = result["user"];
}

main();

Try again

hdalang
Champ in-the-making
Champ in-the-making
thanks for the reply, but I tried it and it's still the same, also I have changed the hellouser.get.html.ftl
the ${hellouser} to ${user}, I think my problem is that the alfresco isn't able to update the dashlet. I have tried to restart and also refresh the webscript but there's no use from doing that, it's still the same.

hdalang
Champ in-the-making
Champ in-the-making
OK, it worked thanks for your help.

kachaj7
Champ in-the-making
Champ in-the-making
hdalang what do made to update the javascript dashlet?