cancel
Showing results for 
Search instead for 
Did you mean: 

Mixing JSP with HTMLB

Former Member
0 Kudos

Hi

I try to mix JSP code with htmlb and it is not working as I want it to.

I try to create a tree with dynamic nodes, this using the htmlb tree which can be found in the documentation.

I open the tree static with:

<hbj:tree id="1" title="" rootNodeIsVisible="FALSE">

<hbj:treeNode id="rootinv" text="_" isOpen="TRUE">

I also close it later.

Inbetween I loop out the nodes and subnodes with the code:

<%if(Integer.parseInt(sMenuProdElements[k][3])==0){%>

<hbj:treeNode id="<%=p%>" text="<%=s%>" isOpen="FALSE">

<%}else if(Integer.parseInt(sMenuProdElements[k][3])==1){%>

<hbj:treeNode id="<%=p%>" text="<%=s%>"/>

<%}%>

I also have code for closing the treenode. I have tried with writing out plain text, so I know that it is writing the nodes in correct order.

How do I solve this issue. Should I save ready made htmlb code in the vector already in my dynpage and set it in the bean and then write it out in the JSP file. Anyone who had the similar problem who knows how to solve this issue?

Brgds// -Fred

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

I know that it is possible to add onNodeClick to a treeNode using this code:

<hbj:treeNode id="hello" text="helloWorld"><% hello.setOnNodeClick("nodeSClick"); %></hbj:treeNode>

But this does not work for my solution, I'm looping all the values out and the id is dynamic. So, writing a code snippet that says:

<hbj:treeNode id="<%=vElem[0][1]%>" text="helloWorld"><% vElem[0][1].setOnNodeClick("nodeSClick"); %></hbj:treeNode>

Does not work. Anyone have any suggestions how to resolve this issue?

Brgds// -Fred

Former Member
0 Kudos

What you code is actually doing in the java section is to try to call the method setOnNodeClick on the string class (which of course doesn't exist).

I've had the same problem earlier (looping with dynamic ids) and as far as i remember i was managed to solve with by only using the properties in the htmlb tag. I think there is a onNodeclick property on the treenode tag, so that you could would be

<hbj:treeNode id="<%=vElem[0][1]%>" text="helloworld" onNodeClick="nodeSClick"/>

But it would be much better for you to build your tree in a java class (or in a function in the jsp) using the tree node api, and then add the root node to the treeView

Former Member
0 Kudos

Hi and thanks for your answers

It says that it expects while instead of if. So I changed this and used a different code snippet to read it all out and was successful! The tree is there.

But now I realised that there are no event handling in JSP taglib for the treeNode. Is this true, do I have to render the whole iview in dynpage in order to be able to use the eventhandling, or is there a workaround?

// -Fred

Former Member
0 Kudos

<b>Hi again</b>

The problem is that I can't use the java class and render the tree in the dynpage. I have a lot of other code for othter type of functionality in the iview that I don't want to rebuild. Have anyone got a clue how I should solve this. Implementing a dynamic tree, as I said above it does not work to mix JSP with htmlb in this case, maybe there is another way.

<b>

Brgds// -Fred</b>

Former Member
0 Kudos

What is the compile error ? The complete stack trace would be useful

Former Member
0 Kudos

I get a compile error.

I will try with the java class instead.

Thanks

Former Member
0 Kudos

What is the exact problem ? Do you get a compile exception or is the functionality not what you expected.

Remember that the id must be unique (and often it is better to use the javaclasses directly to build the tree structure instead of htmlb)