Skip to main content

New VWP jMaki blog and a question about the Yahoo Tree Widget

4 replies [Last post]
Joined: 2003-07-09
Points: 0


I just posted a new blog entry about how to add jMaki 9.3 to a NetBeans VWP or Sun Java Studio Creator project. If you see any misinformation, errors, or better ways to do it, let me know. See

I have a couple of questions about the default tag for the widget

1. Why is it publishing to the /jmaki/menu topic?
2. What is with the onclick? I tried various ways to set the url but never got it to work. Nor did I see any samples that use this that actually work.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2005-04-18
Points: 0

I have a small demo that updates a dynamic container based on the URL set in my Dojo tree. With that said, let me mention that my example is with JSPs and Struts - not sure if there are [i]any[/i] differences with JSFs (which your demos use). If so, sorry for the irrelevance of my comments here.

Also, while working on the demo, I noticed that the component.js for the Dojo tree had a line that looked like: if (typeof root.onClick != 'undefined') around line 58. The C in click is capitalized. I changed it to lower case and the proper payload showed up in my event (with URL). I was writing a bug report when I decided to check the same file in other NetBeans projects and the C was [b]not[/b] capitalized! I decided to check because I was previously mucking around in that file. Now I was unsure whether the problem always existed or I introduced it (I have projects using various versions of jMaki). Unfortunately I did not pursue it further. With that said (and if you are still reading), here is what I did:

I first generated my tree data from a business object. The data was generated using JSONObjects. Here is a snippet for the URL part:

for (int i=0; i<teams.length; i++) {
   JSONObject teamObj = new JSONObject ();
   teamObj.put ("title", teams[i].getTeamName ());
   teamObj.put ("expanded", true);

   JSONObject teamUrl = new JSONObject ();
   teamUrl.put ("url", ateams.buildUserLink2 (teams[i].getTeamName ()));
   teamObj.put ("onclick", teamUrl);


The constructed URL link calls a Struts .do file with the provided name as a parameter:


All this is so I can dynamically generate my JSON string from my server-side business objects. I then call the appropriate method from my JSP to populate the jMaki widget. Thanks to Greg Murray, I have some methods that can be used to convert JSONObject to a string literal for use in the value attribute of a jMaki widget (see So, on my JSP I have:

<jsp:useBean id="teams"

<a:widget name="dojo.tree"
   args="{topic : '/tree/org'}"

   function orgTreeListener(args) {
      jmaki.publish("/jmaki/mycontainer", args.url);
   jmaki.subscribe("/tree/org", orgTreeListener);

Note I provide a customized topic for the widget (/tree/org). Dojo tree does not currently support this, so I had to do a small change to its component.js (see

Elsewhere on my JSP I have the dynamic container widget:

<a:widget name="jmaki.dcontainer" args="{topic:'/jmaki/mycontainer', url:''}" />

Notice that the container is listening on the same topic I publish to when I select a tree node. The container updates with the URL associated with the selected node and all is good.

I realize this is pretty long-winded, but hopefully it helps.

Joined: 2003-07-09
Points: 0

Thanks, I will give this a try.

Joined: 2005-02-10
Points: 0

Here is the response I got from Greg. You will need to add some code in glue to get this
work for now.

for details.


Joined: 2005-02-10
Points: 0


1. I'm guessing that it is publishing to /jmaki/menu because the dcontainer is subscribed to that topic and so out of the box if you have a dcontainer in the page and you click on a url in the tree then that url is automatically loaded by the dcontainer.

I know we need to make that clearer and if you have some feedback please join in on the discussion on the dev list.

Not sure what onClick followed by a url is supposed to do. I thought it means that when the user clicks on that node the url would be published. The dcontainer would then pick that up and load the page. I tested this and it failed. I'll send email to the dev alias asking what it is supposed to do and file a bug if needed.