Skip to main content

Dynamic jMaki dojo tree selection

2 replies [Last post]
hovanessyan
Offline
Joined: 2008-01-15

Hi all, I need help on node selection of a dynamically constructed jMaki tree.

Basically what I need is a page, where I have html text input field (disabled)
and the tree, beneath the input field.

When I select a node from the tree, I want the name of the node to be displayed in the input field.

Here's the code of my page:

#################################################
A JSP page, which the user will see
#################################################

<%@ taglib prefix="a" uri="http://jmaki/v1.0/jsp" %>

1. the value - JSONBean.json_string is a JSON string, which constructs the tree. The string is generated from a XML file using pure Java - parsing(XML - to - java objects) + JSONObject + JSONArray.

I don't know if I should have something like

JSONObject any_node = new JSONObject();
any_node.put("title", "a_title");
any_node.put("children", "some_children");
any_node.put("action", "{some array of arguments containing topic + action}"); ( ?? )

to add action to each of the nodes....

Or should I do some work in glue.js file...
Please help me, any suggested documentation will be appreciated!

Thank you in advance!

Message was edited by: hovanessyan

Message was edited by: hovanessyan

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
hovanessyan
Offline
Joined: 2008-01-15

Yep, using put(String, Collection) fixes the problem.

HashMap map = new HashMap();

map.put("topic", "/foo/select");
map.put("message, "whatever");

JSONObjectForTreeNode.put("action", map);

produces the desired String without the single quotes :)...

hovanessyan
Offline
Joined: 2008-01-15

I've just tested that treating each node in this manner:

JSONObjectRepresentingANode.put("action", ACTION);

where ACTION is a string:

ACTION = "{ topic : '/foo/select', message : 'UID' }"

works ok - > but there's a problem.

In the generated JSON file, this looks like:

action: '{ topic : '/foo/select', message : 'UID' }'

The trouble comes from the single quotes after " action : "
and at the end of the string.

Do you know some way to omit those quotes ?
It seems the PUT method puts the single quotes, only if the value is String.