开发者

rich:tree -- unable to generate leaves dynamically?

I have some trouble working with dynamically-generated trees, i.e. trees whose leaves are read from 开发者_如何学Cthe database.

In my app, I am showing a list of problems (in a rich datatable). When the user clicks on a problem, a tree containing names of photos associated to that problem is shown. Even though the photos associated to the selected problem are correctly read from the database, the tree's leaves contain only the default test values that I set in the beginning.

Relevant snippets:

The tree is contained in a form and it looks like this:

<rich:tree style="width:300px" 
    nodeSelectListener="#{treeBean.processSelection}"
    reRender="selectedNode" 
    ajaxSubmitSelection="true" 
    switchType="server" 
    value="#{treeBean.treeNode}">
</rich:tree>

And in the bean I have the method for getting the treeNode: public TreeNode getTreeNode()

I have debugged this and I don't understand how it works. Does something else happen to the value of treeNode between the return of getTreeNode() and the displaying in the rich:tree? I print out the value of treeNode right before the return of getTreeNode() and it is correct, but the displayed value is not the one printed out.

Can anyone explain why this happens and/or how this works internally? Thanks!

EDIT: After debugging in more detail, I think that the getTreeNode() method is only invoked once, during rendering of the page on which the tree will be shown. How can the rich:tree component be forced to call this method every time the tree is to be shown?


Solved by re-rendering the tree. There might be a more elegant solution, but this works for now.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜