cancel
Showing results for 
Search instead for 
Did you mean: 

Determining which tree node is calling an event

Former Member
0 Kudos

Hi all,

I am currently working on a project that involves a tree which can consist of about 800+ tree nodes based on the end-user's access rights. The main issue with this was the performance. In improving the performance, I created a new problem.

Here is the performance improvement:

At first, I read in all 800+ data and created the tree nodes in one initialization method. However, performance was so bad that I needed to redo the logic. I came up with the idea to render only the first level tree nodes first. Then on a user's expand/click of the tree nodes, the selected tree node will append its child nodes only for that selected tree node. This improves the performance dramatically.

Because of the new logic, I need to know which tree node is being selected. This is what I don't know how to do.

NOTE: I AM USING JSPDynPage.

-


Code:

// all root nodes is at menu level 1, these are the nodes

// which will be rendered on initialization

// menu level 2 will be appended on a user's click/expand

// action

if (menulevel == 1) // root node

{

TreeNode newNode = new TreeNode(id, name, parentnode);

newNode.setOnNodeExpand("RootNodeExpandEvent");

newNode.setOnNodeClick("RootNodeClickEvent");

}

// event handler

public void RootNodeClickEvent(Event event)

{

// i want to be able to determine which node

// is selected here

}

public void RootNodeExpandEvent(Event event)

{

// i want to be able to determine which node

// is selected here

}

-


I am fairly new to portal development. Gurus, please provide me with some of your knowledge on this issue. The deadline for the project is right around the corner.

Thanks in advance.

- Lay Gauv

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Lay,

You do the following.

public void RootNodeClickEvent(Event event)
{
 TreeNodeSelectEvent nodeselect = (TreeNodeSelectEvent) event;
 String node_key = nodeselect.getNodeKey();
}

public void RootNodeExpandEvent(Event event)
{
TreeNodeExpandEvent nodeselect = (TreeNodeExpandEvent) event;
String node_key = nodeselect.getNodeKey();
}

PS: Please reward points for helpful answer or problem resolved.

Former Member
0 Kudos

Thanks. However, what library do I need to import to be able to use TreeNodeSelectEvent? I am getting "TreeNodeSelectEvent cannot be resolved or is not a type." error.

Former Member
0 Kudos

it is in <b>htmlb.jar</b>.

Former Member
0 Kudos

I have the following two htmlb.jars already assoicated with the project. Yet it does not work.

.\pdk_libs\devlibs\htmlb.jar

.\pdk_libs\portalapps\htmlb.jar

Do I need a certain import tag at the top of the java file?

i.e. import com.sapportals.htmlb.TreeNode;

Former Member
0 Kudos

Eclipse automatically can put the following import statement. If you want you can manually put the following lines at the top.

import com.sapportals.htmlb.event.TreeNodeExpandEvent;

import com.sapportals.htmlb.event.TreeNodeSelectEvent;

email me at psingh@ust.net. I will send you my jar file. I think you might be using a old jar file.

Former Member
0 Kudos

I had to manually entered in there. Thanks a whole lot. It works.

Former Member
0 Kudos

Hey Prakash,

After getting the id of the clicked node..how wud i use the setOpen() function of the TreeNode tag?

Someone asked the same Question, like how to set the treenode open based on the id we get with the method u have given...

Can you paste a small code piece??

Thanks

Answers (0)