cancel
Showing results for 
Search instead for 
Did you mean: 

How to get context in javascript

andrewriver
Champ in-the-making
Champ in-the-making
Hi! I want to get the alfresco share context ([server]:9080/share) in one javascript function of my custom dashlet (not the .get.js)

Any idea?? Thanks
3 REPLIES 3

ghl
Champ in-the-making
Champ in-the-making
If you are asking about how to get the context path directly from JavaScript (in the client), I do not think that is possible.

You can however, define the value in a JSP like so;


<script …>
var contextPath = '<%= request.getContextPath() %>';
</script>

andrewriver
Champ in-the-making
Champ in-the-making
No I can't…there is no JSP, just ftl, js…a share dashlet.

ghl
Champ in-the-making
Champ in-the-making
The freemarker templates have the TemplateNode Model to your disposal.  You can inject the context path into your template similar to how I suggested using JSP's using the url templateNode object (url.context).  Implementation details really  :wink:

http://wiki.alfresco.com/wiki/Template_Guide#TemplateNode_Model_API