AnsweredAssumed Answered

Adding YUI Widgets Using Webscripts

Question asked by stevericker on Dec 26, 2009
Latest reply on Feb 3, 2010 by mikeh
Hello All,

We're adding a YUI widget (a treeview) as a dashlet.  But we have some questions as to how to do this correctly using webscripts.  There seem to be several examples of similar things built into Share, but we get lost as we try to plow through all the technologies that are involved (e.g., YUI, Freemarker, webscripts, Share).

Here's what we've tried:

- Built a webscript called "treenav" (treenav.get.desc.xml, *.get.html.ftl, *.get.head.ftl, *.get.js)
- Made the <family> a dashlet in the descriptor
- Added all the YUI treeview javascript code to the response template, treenav.get.html.ftl (see below)


Test dashlet
<div id="treeDiv1">gee</div>

<script type="text/javascript">//<![CDATA[

var tempobject = [ { type: "text", label: "node1" } ];

//instantiate the TreeView control:
var tree = new YAHOO.widget.TreeView("treeDiv1", tempobject);

//render it


- Registered it
- Added the dashlet to a dashboard
- It works (the YUI treeview shows up)

Here's one question:

- It doesn't seem like adding the javascript to the response template (*.get.html.ftl) is all that elegant (and kind of messes up the MVC pattern)
- But the YUI treeview seems to need its target (the <DIV> tag where the treeview will go) before being instantiated
- So putting the javascript in the controller (treenav.get.js) or in a client side file (treenav.js) doesn't seem to work
- Is there a more correct way to do this?

Here's another question:

- We want to try to get some user site information while we're building the treeview in the response template (treenav.get.html.ftl)
- When we try to use "" in our javascript, we get the error "remote is not defined" (in Firebug)
- But the remote object seems accessible per
- Is it not possible to use the root object "remote" within javascript embedded in the response template?

And a final, more general, question:

- Let's say, from our controller script, we put data in our model root object
- How can we access that model root object data from our response template w.o. using a Freemarker interpolation (${somedata})?
- In particular, if we have javascript in our response template, can we get access to the model root object?

Hopefully this is not too longwinded.  But any help on the above would be really appreciated and would really help us as we try to continue to figure out how best to use the platform (by the way, we're using Alfresco Share 3.2r community w. Tomcat).  It seems like our troubles and questions are probably due to some misunderstandings we have about webscripts.

Thank you!