-
1. Re: How to add AJAX to TreeNode?
lfryc Jun 4, 2013 9:42 AM (in response to td121136)Hey Alfred,
have you tried to review the browser error console?
I expect that the tree resources aren't initialized correctly and you will see some errors.
-
2. Re: How to add AJAX to TreeNode?
lfryc Jun 4, 2013 9:45 AM (in response to td121136)Note that creating components by calling new <UIComponent()> is not recommended,
you should use Application.createComponent instead.
-
3. Re: How to add AJAX to TreeNode?
td121136 Jun 4, 2013 6:46 PM (in response to lfryc)I'm using Firefox version 17, how can i view the JSF errors?
-
4. Re: How to add AJAX to TreeNode?
td121136 Jun 4, 2013 11:08 PM (in response to td121136)OK, i figured it out how to open the error browser in Firefox using CTRL + SHIFT + J
Once opened the browser i try to reload the page again, i found an error in the browser as follow:
TypeError: RichFaces.ui.Tree is not a constructor
Any idea?
-
5. Re: How to add AJAX to TreeNode?
lfryc Jun 7, 2013 4:34 AM (in response to td121136)JavaScript dependencies for Tree are missing.
----
As I told you, you need to use JSF way to create a component [1] and then add it to a component tree [2].
UIComponent comp = Application#createComponent
FacesContext.getViewRoot().getComponents().add(comp);
Now, the JavaScript dependencies for Tree should be loaded in a browser.
----
The statement above ^ expects you add the component in an initial request (not postback).
The resources for AJAX postbacks won't be loaded correctly.
You can overcome that by loading all RichFaces at once (known as RichFaces Resource Optimization feature).
Or you can load them one by one on a views you need them:
<h:outputScript library=... name=... />
<h:outputStylesheet library=... name=... />
You can find all required resource names (as a pair resource name / resource library) at:
-
6. Re: How to add AJAX to TreeNode?
td121136 Jun 7, 2013 6:51 AM (in response to lfryc)Yup, i did follow the way as you mentioned, create the component using Application.createComponent(), but the result is still the same..
I followed the way to creare the component, and now there is no more error message in the broswer, the richtree showed but clicked on the tree node doesnt invoke the ajax call.
I had do a simple test by adding the <rich:tree> along with the <rich:treeNode> directly in the xhtml file, e.g.:
<rich:tree id="testTree" value="#{manager.getRoot()}" var="item" nodeType="#{item.getType()}">
<rich:treeNode type="testTreeNode">
<a4j:ajax event="click" execute="@this" action="#{selectionManager.setSelectedNode(item)}" render="leftHandSide"/>
<h:outputText value="#{item.getData().getName()}" styleclass="openet-node-active-true"/>
<a4j:commandButton id="testbutton" type="button" execute="@this" value="test" action="#{manager.setSelectedNode(item)}" render="left,right"/>
</rich:treeNode>
</rich:tree>
</h:form>
When clicking on the treenode (the outputtext), it did fire an ajax call, however it doesnt call to the method as i expected. However the same thing works when i creating a commandbutton (as showed above), it called the expected method. But this is just for testing, i still need to get thing work in the dynamic side. Current i'm using the <ui:debug> to check the component on the page, is there any useful tools which i can used to view the dynamic generated content, similar like xhtml, or is there any debug mode i can enabled to view them?