Is it possible to invoke reRender from Javascript?
scotto Mar 15, 2007 11:21 PMIn my application I have a <rich:tree> of <rich:treenode> elements generated from a database-backed tree structure. The web-interface also uses Seam remoting functionality to subscribe to a JMS topic that asynchronously broadcasts changes to the tree state.
I have a client-side Javascript callback that is invoked in response to the JMS notifications and I need this script to invoke a reRender() on the corresponding node in the tree in order to redraw the updated node view.
Is this possible with RichFaces?
I have not had any success with this so far, as I cannot seem to set the node 'id' attribute from an EL expression. Using this JSF template:
<rich:tree value="#{topologyTreeModel.treeModel}" var="item" nodeFace="#{item.type}"> <rich:treeNode type="Device" iconLeaf="#{item.icon}" id="n-#{item.identifier}"> <h:commandLink action="#{nodeView.begin}"> <f:param name="node" value="#{item.identifier}"/> <h:outputText value="#{item.description}" /> </h:commandLink> </rich:treeNode> ... </rich:tree>
Results results in this exception (note that the #{item.identifier} expression evaluates correctly in the <f:param> tag, just not in the ID attribute):
SEVERE: Error Rendering View[/console/topologytree.xhtml] java.lang.IllegalStateException: Component ID j_id5:j_id21:n- has already been found in the view. See below for details. ... <div class="topologyTree"> +id: j_id21 type: org.richfaces.component.html.HtmlTree@f5f77 +id: n- type: org.richfaces.component.html.HtmlTreeNode@1449d75 +id: j_id22 type: javax.faces.component.html.HtmlCommandLink@1bd9f3d +id: j_id23 type: javax.faces.component.UIParameter@217540 +id: j_id24 type: javax.faces.component.html.HtmlOutputText@98fc6a +id: n- type: org.richfaces.component.html.HtmlTreeNode@1e3d101 +id: j_id25 type: javax.faces.component.html.HtmlCommandLink@1ae9aa5 +id: j_id26 type: javax.faces.component.UIParameter@2af8bd +id: j_id27 type: javax.faces.component.html.HtmlOutputText@130478f +id: n- type: org.richfaces.component.html.HtmlTreeNode@aa1162 +id: j_id28 type: javax.faces.component.html.HtmlCommandLink@15b6354 +id: j_id29 type: javax.faces.component.UIParameter@d62dd4 +id: j_id30 type: javax.faces.component.html.HtmlOutputText@15abfe1 ...
See how every TreeNode is given id="n-" rather than id="n-123" etc? Is there a way to get this to work?
The thing is, I was able to get this approach working with Tomahawk Tree2 by surrounding the node contents with a tag and then manually replacing the contents. However I really would like to use the reRender functionality of the RichFaces tree instead of manual Javascript DOM hacking.
Any clues as to how I might go about this?
Thanks again for your help!
Scott