cancel
Showing results for 
Search instead for 
Did you mean: 

custom a dashlet with a external JS Code

alibel
Champ in-the-making
Champ in-the-making
Hello,

I'am a new user in Alfresco developpement.

I want to add a new dashlet in my share dashborad with an external JS code. My JS code contains ressources like css files or js files.
I did all the tutorials for add a Dashlet in dashboard but with my JS code and my ressources I have an error in dojo.js "multidefine".

Can you define me if I have to set some thing in alfresco or share, or something else?

Thanks.

error :

Error: multipleDefine
Trace de la pile :
_f@http://127.0.0.1:8080/share/res/js/lib/dojo-1.9.0/dojo/dojo.js:15:430
_f7@http://127.0.0.1:8080/share/res/js/lib/dojo-1.9.0/dojo/dojo.js:15:16091
_7d/<@http://127.0.0.1:8080/share/res/js/lib/dojo-1.9.0/dojo/dojo.js:15:16665
_9@http://127.0.0.1:8080/share/res/js/lib/dojo-1.9.0/dojo/dojo.js:15:322
_7d@http://127.0.0.1:8080/share/res/js/lib/dojo-1.9.0/dojo/dojo.js:15:16639
_32/_f1@http://127.0.0.1:8080/share/res/js/lib/dojo-1.9.0/dojo/dojo.js:15:14695
_32@http://127.0.0.1:8080/share/res/js/lib/dojo-1.9.0/dojo/dojo.js:15:15008
_e8@http://127.0.0.1:8080/share/res/js/lib/dojo-1.9.0/dojo/dojo.js:15:13856
_32@http://127.0.0.1:8080/share/res/js/lib/dojo-1.9.0/dojo/dojo.js:15:14659
_9@http://127.0.0.1:8080/share/res/js/lib/dojo-1.9.0/dojo/dojo.js:15:322
_79/<@http://127.0.0.1:8080/share/res/js/lib/dojo-1.9.0/dojo/dojo.js:15:6748
_37@http://127.0.0.1:8080/share/res/js/lib/dojo-1.9.0/dojo/dojo.js:15:13094
_79@http://127.0.0.1:8080/share/res/js/lib/dojo-1.9.0/dojo/dojo.js:15:6733
_16@http://127.0.0.1:8080/share/res/js/lib/dojo-1.9.0/dojo/dojo.js:15:7399
req@http://127.0.0.1:8080/share/res/js/lib/dojo-1.9.0/dojo/dojo.js:15:549
@http://127.0.0.1:8080/share/page/user/admin/dashboard:235:1
8 REPLIES 8

ddraper
World-Class Innovator
World-Class Innovator
You've not really provided a lot of information to go on here… maybe you can provide more information on how you're defining your dashlet WebScript, what resources you're trying to include and how you're trying to use them.

alibel
Champ in-the-making
Champ in-the-making
thanks for your answer.

I explain you my procedure to create my dashlet:

- I created 2 files: myScript.get.desc.xml and myScript.get.html.ftl in the directory path: \tomcat\webapps\share\WEB-INF\classes\alfresco\site-webscripts\org\alfresco\components\dashlets

- I integrated a script library and style files in the directory path:
Alfresco\tomcat\webapps\share\components\dashlets

- I call this script library and these style files in my myScript.get.html.ftl with the syntax for example :

<@markup id="js">
<@script type="text/javascript" src="${url.context}/res/components/dashlets/directory/Script.js" group="dashlets" />
</@>

In the last, I restart service of alfresco , I open the share dashboard, I insert the dashlet with dashboard customization, I save and there is nothing on the dashborad (menu and dashlet). In the debug tool on the browser I see the above error.

I remain at your disposal for others informations.

Thanks

ddraper
World-Class Innovator
World-Class Innovator
What's in script.js? Are the markup and script tags the only think in the .html.ftl file?

alibel
Champ in-the-making
Champ in-the-making
The script.js is leaflet.js , I get it library leaflet, there are inside many functions to initialize and manipulate a geographic map.

And in my .html.ftl file there are not only markup and script tags, there are javascript code.

I specify that this code works very well when I put it in the form of webScript .  

alibel
Champ in-the-making
Champ in-the-making
Any response?

ddraper
World-Class Innovator
World-Class Innovator
I've been trying to nudge you to provide some useful information to help diagnose your issue… but you're really not providing anything to go on, this is almost certainly why no-one has been able to help you.

alibel
Champ in-the-making
Champ in-the-making
I 'll try to be as specific as possible:

My target :
display on the dashboard a dashlet with a geo views that I will handle later

the procedure that I followed:

- I create two files to create my dashlet in "Alfresco\tomcat\webapps\share\WEB-INF\classes\alfresco\site-webscripts\org\alfresco\components\dashlets": nameOfMyDashlet.get.desc.xml and nameOfMyDashlet.get.html.ftl
           file content:





                       XML:
<webscript>
<shortname>Hello World</shortname>
<description>Displays Hello World text to the user</description>
<family>dashlet</family>
<url>/components/dashlets/hello-world</url>
</webscript>









          TEMPLATE:

<@markup id="css" >
   <@link rel="stylesheet" href="${url.context}/res/components/dashlets/leaflet/leaflet.css" group="dashlets"/>
   
  <@link rel="stylesheet" href="${url.context}/res/components/dashlets/leaflet/lib/labels/leaflet.label.css" group="dashlets"/>
</@>

   
<@markup id="js">
   
   <@script type="text/javascript" src="${url.context}/res/components/dashlets/leaflet/leaflet.js" group="dashlets" />
   <@script type="text/javascript" src="${url.context}/res/components/dashlets/leaflet/lib/labels/leaflet.label.js" group="dashlets"/>

   <@script type="text/javascript" src="${url.context}/res/components/dashlets/carroyage2.js" group="dashlets"/>
   <@script type="text/javascript" src="${url.context}/res/components/dashlets/carreau_texte.js" group="dashlets"/>
   
</@>
<@markup id="widgets">
   <@createWidgets group="dashlets"/>
</@>

<style>
      #map {
         width: 300px;
         height: 100px;
         margin: auto;
      }

      .info {
         padding: 6px 8px;
         font: 14px/16px Arial, Helvetica, sans-serif;
         background: white;
         background: rgba(255,255,255,0.8);
         box-shadow: 0 0 15px rgba(0,0,0,80.2);
         border-radius: 5px;
      }
      .info h4 {
         margin: 0 0 5px;
         color: #777;
      }

      .legend {
         text-align: left;
         line-height: 18px;
         color: #555;
      }
      .legend i {
         width: 18px;
         height: 18px;
         float: left;
         margin-right: 8px;
         opacity: 0.7;
      }
      h1{
      text-align: center;
      }
   </style>

   
      
<@markup id="html">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<div class="dashlet">
<div class="title">Hello World!</div>
<div class="detail-list-item first-item last-item">
<span>Hello</span>
<meta charset="utf-8" />

<h1> Cartographie </h1>
   <div id="map"></div>
   <div class="info"></div>
<script type="text/javascript">

"My script to initialize my map with options "

</script>

</div>
</div>
</@>

- I I place a library file in the following path: Alfresco\tomcat\webapps\share\components\dashlets\leaflet

- I restart all service of alfresco

- I log on alfresco share dashboard
- I click on customize my dashboard , my dashlet exists but when I  add it to the dashboard there is nothing on my dashbord and on the debug tools I have dojo.js error : multipledefine

Sorry, but this time I can not be must specific.

Thank you for your response