-
1. Re: Problem to keep rich:tree state
blabno Sep 5, 2008 8:26 AM (in response to fvalente)Info on how to use stateAdvisor is in richfaces tlddoc.
adviseNodeOpened : javax.el.MethodExpression
(signature must match void adviseNodeOpened(org.richfaces.component.UITree)) MethodBinding pointing at a method accepting an org.richfaces.component.UITree with return of java.lang.Boolean type. If returned value is: java.lang.Boolean. TRUE, a particular treeNode is expanded; java.lang.Boolean.FALSE, a particular treeNode is collapsed; null, a particular treeNode saves the current stateAs to NoClassDefFoundError, you do not have richfaces-ui.jar in your classpath. Put all 3 richfaces jars in EAR/lib or if you use WAR only, put it in WEB-INF/lib.
And one more thing. When you use your tree between conversations make your advisor session scoped.
-
2. Re: Problem to keep rich:tree state
vladimir.kovalyuk Sep 5, 2008 10:34 AM (in response to fvalente)For what reason we should include richfaces-impl.jar into ear/lib if there is richfaces-api?
-
3. Re: Problem to keep rich:tree state
fvalente Sep 5, 2008 4:20 PM (in response to fvalente)I solved the problem.
I used the attribute componentState from the tree component.
I have to show several trees at the same time and keep the state of all of them.
So I created a controller with scope SESSION and added a Map<HierarchicalClassifier, TreeState> with getter and setter (both passing a HierarchicalClassifier argument) for the map.
Concerning the problem of NoClassDefFoundError, I added the richfaces-ui.jar in my classpath.
[]'s
-
4. Re: Problem to keep rich:tree state
safa Feb 3, 2009 10:04 AM (in response to fvalente)hi, fabio,
I'm having the same problem,
Can you, plz, give more details on how you resolve it??
I really need your help
Thx
-
5. Re: Problem to keep rich:tree state
fvalente Feb 3, 2009 11:39 AM (in response to fvalente)TreeStateController.java
@Name("treeStateController") @Scope(ScopeType.SESSION) @AutoCreate public class TreeStateController extends Controller { private Map<Integer, TreeState> treeStateMap = new HashMap<Integer, TreeState>(); public TreeState getTreeState(Integer key) { TreeState treeState = treeStateMap.get(key); if (treeState == null) { treeState = new TreeState(); treeStateMap.put(key, treeState); } return treeState; } public void setTreeState(Integer key, TreeState treeState) { treeStateMap.put(key, treeState); } }
inc_tree.xhtml
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:s="http://jboss.com/products/seam/taglib" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:rich="http://richfaces.org/rich" xmlns:a4j="http://richfaces.org/a4j"> <rich:tree switchType="client" componentState="#treeStateController.getTreeState(tree.id)}"> <rich:recursiveTreeNodesAdaptor roots="#{tree.activeRootElements}" var="element" nodes="#{element.activeChildrenElements}"> <rich:treeNode> <s:link view="/viewElement.xhtml"> <f:param value="#{element.id}" name="elementId"/> <h:outputText value="#{element.title}"/> </s:link> </rich:treeNode> </rich:recursiveTreeNodesAdaptor> <a4j:support event="oncollapse" ajaxSingle="true" /> <a4j:support event="onexpand" ajaxSingle="true" /> </rich:tree> </ui:composition>
-
6. Re: Problem to keep rich:tree state
axelpaul Feb 19, 2009 8:06 PM (in response to fvalente)Fabio . Thank you very much for your example, I've working on an app that requires the rich tree component state and your solution was very useful to me. Only want to say thank you.
-
7. Re: Problem to keep rich:tree state
joblini Feb 20, 2009 1:18 AM (in response to fvalente)Fabio, Please accept my thanks also. Your example is solid gold for me!