cancel
Showing results for 
Search instead for 
Did you mean: 

Javascript API - variable 'site' for dashlet

nancygaillard
Champ on-the-rise
Champ on-the-rise
Hi,

I am working on a Windows 7 64bits with Alfresco 4.2.e

I have created a dashlet. I would like it shows a list of datalists of a particular site, but the dashlet has to be in the main dashboard.

I can obtain a result but not that i would like to have. I dont know how to access directories.
-> I have tested the remote.call function but i dont know what i can write for the uri…
-> I have trying use siteservice too with siteService.getSite("administratif")…

I have in tomcat\webapps\share\WEB-INF\classes\alfresco\site-webscripts\org\alfresco\components\dashlets :

- datalists-list.get.desc.xml
- datalists-list.get.html.ftl
- datalists-list.get.js


datalists-list.get.desc.xml :

<webscript>
    <shortname>Appels et Courriers</shortname>
    <description>Liste des listes d'appels et de courriers</description>
    <family>user-dashlet</family>
      <url>/components/dashlets/datalists-list</url>
</webscript>


datalists-list.get.html.ftl

<@markup id="js">
   <#– Your JavaScript file. You actually only need the my-dashlet-min.js file (unless in development mode), but we usually keep the original source in my-dashlet.js there so we can change it later.–>
   <@script type="text/javascript" src="${url.context}/res/components/dashlets/datalists-list.js" group="dashlets"/>
</@>
<@markup id="html">
  <@uniqueIdDiv>
      <div class="dashlet">
         <div class="title">Lites d'appels et de courriers</div>
         <div class="body">
            ${msg[0]} - ${msg[1]} - ${msg[2]} - ${msg[3]}<br/>
            <#if listes?exists>
               <#if listes?is_boolean>
                  Aucune liste d'appels ou de courrier
               <#else>
                  <#list listes as liste>
                     <a href="${url.serviceContext}/repo/node/${liste.id}">${liste.title}</a><br/>
                  </#list>
               </#if>
            <#else>
               liste non défini
            </#if>
         </div>
      </div>
   </@>
</@>


datalists-list.get.js :

<import resource="classpath:/alfresco/templates/org/alfresco/import/alfresco-util.js">
var listes = false;
var msg = [];

var dossier = sites.childByNamePath("Sites").childByNamePath("administratif");
if(dossier && dossier.childByNamePath("dataLists")){
   dossier = dossier.childByNamePath("dataLists");
   listes = dossier.children;
   msg[0] = "dossier Site et administratif trouvé";
}else msg[0] = "dossier sites et administratif non trouvé";

model.listes = listes;
model.msg = msg;
4 REPLIES 4

kaynezhang
World-Class Innovator
World-Class Innovator
Please visit http://localhost:8080/alfresco/service/index/all using admin account,all the urls you can call in remote.call function are there.

nancygaillard
Champ on-the-rise
Champ on-the-rise
Thank you Smiley Happy

I can obtain a result directly when I tried the following url with my navigator:
http://localhost:8081/alfresco/service/cmis/p/Sites/gestion/dataLists/children
(my alfresco turn on 8081)

but in datalists-list.get.js, when i do :
<javascript>
var json = remote.call("/alfresco/service/cmis/p/Sites/gestion/dataLists/children");
model.status = json.status;
</javascript>
and show ${status} in my .ftl

I obtain 404…

What is the problem?

kaynezhang
World-Class Innovator
World-Class Innovator
404 is a url not found error,which means ,try this

var json = remote.call("/service/cmis/p/Sites/gestion/dataLists/children");


nancygaillard
Champ on-the-rise
Champ on-the-rise
with
<javascript>var json = remote.call("/service/cmis/p/Sites/gestion/dataLists/children");</javascript>
I find 200.
[thanks to https://forums.alfresco.com/forum/developer-discussions/alfresco-share-development/how-get-content-c... too]

You helped me a lot! Thank you Smiley Happy