Board index JavaServer Faces General Tree doesn't work with 2.0.2

Tree doesn't work with 2.0.2

Components, Ajax Framework, Utilities and More.

Post 25 May 2010, 17:21
Oleg User avatar
Expert Member

Posts: 3713
Location: Russia, Siberia => Germany, Black Forest
Hello Cagatay,

My tree doesn't work more after update to PrimeFaces 2.0.2. No expand, no select more. I have figured out I need selection="single" (was not nessesary with 2.0.1), but PrimeFacesPhaseListener says after its adding "tree id is not found to be updated partially". The tree:

<p:tree id="treeSocs" value="#{socsBean.socsRootNode}" var="socNode" dynamic="true" cache="true"
   selectionMode="single" nodeSelectListener="#{socsBean.onNodeSelect}" nodeExpandListener="#{socsBean.onNodeExpand}"
   update="dtSelTreeSocGroup,dtSocsGroup,mbPropDefs" onNodeClick="handleTreeSocsNodeClick" widgetVar="treeSocsWidget">
   <p:treeNode>
      <h:outputText value="#{socNode.displayName}" escape="false"/>
   </p:treeNode>
   <p:treeNode type="leafSoc" styleClass="leafSoc">
      <h:outputText value="#{socNode.displayName}" styleClass="leafContent" escape="false"/>
   </p:treeNode>
</p:tree>

Please, give me a hint what is wrong here.

The next problem - the entire tree is selected (green).
PrimeFaces 4.x, 5.x, Mojarra 2.2.x, JBoss WildFly, WebSphere, Windows 8.1, IntelliJ IDEA
PrimeFaces Cookbook: http://ova2.github.com/primefaces-cookbook/ PrimeFaces Extensions on GitHub: http://primefaces-extensions.github.com/

Oleg User avatar
Expert Member

Posts: 3713
Location: Russia, Siberia => Germany, Black Forest
I have found I need "selection" as well.

selection="#{socsBean.selectedNodes}"

This is a little bit strange for me because I set selected node in the nodeSelectListener.

I assume, the reason why the entire tree is green is the selection again. If no node is selected the entire tree is selected. Right? How can we avoid this behavior? I don't want to select any nodes if no selection is available.
PrimeFaces 4.x, 5.x, Mojarra 2.2.x, JBoss WildFly, WebSphere, Windows 8.1, IntelliJ IDEA
PrimeFaces Cookbook: http://ova2.github.com/primefaces-cookbook/ PrimeFaces Extensions on GitHub: http://primefaces-extensions.github.com/

Oleg User avatar
Expert Member

Posts: 3713
Location: Russia, Siberia => Germany, Black Forest
Do I see right that pre-selection doesn't work although we have "selection" attribute? What is this attribute then good for? Note: I don't have checkboxes. Selection mode is "single". By the way, for pre-selection you can use my patch.

I have found why my tree is green. In the TreeRenderer (encodeMarkup) you have

      if(selectionEnabled) {
         String selectionClass = tree.getSelectionMode().equalsIgnoreCase("checkbox") ? "ygtv-checkbox" : "ygtv-highlight";
         writer.writeAttribute("class", selectionClass, null);
      }

ygtv-highlight has green color in my CSS.

I have adjusted now my tree to all changes in 2.0.2. One thing is still not nice - selection occupies the entire row and not label only. You can see this here http://www.primefaces.org:8080/prime-sh ... Single.jsf.
PrimeFaces 4.x, 5.x, Mojarra 2.2.x, JBoss WildFly, WebSphere, Windows 8.1, IntelliJ IDEA
PrimeFaces Cookbook: http://ova2.github.com/primefaces-cookbook/ PrimeFaces Extensions on GitHub: http://primefaces-extensions.github.com/


Posts: 15080
Location: Cybertron

Hi Oleg,

Tree selection is rewritten now it supports single, multiple, checkbox and instant single ajax selection so we had to move thing around a little bit. Check out the showcase examples or the user's guide for the new usage. We'll create a migration guide for each release from now on and document the parts that are not backward compatible starting from next release.

You are confusing node focus (old selection, remember it was disappearing) and node selection (highlighting, new way). Focus and Highlight are different things. Highlight is permanent and focus is not.

I can't seem to replicate the whole green issue, what should I do to replicate it, which browser are you testing with?

By default, when a tree is selected (highlighted) whole row gets blue background, this is the default YUI skin which is easy to customize, check out the style selectors;

http://developer.yahoo.com/yui/treeview/#style
PrimeFaces Lead

Oleg User avatar
Expert Member

Posts: 3713
Location: Russia, Siberia => Germany, Black Forest
cagatay.civici wrote:
Hi Oleg,

Tree selection is rewritten now it supports single, multiple, checkbox and instant single ajax selection so we had to move thing around a little bit. Check out the showcase examples or the user's guide for the new usage. We'll create a migration guide for each release from now on and document the parts that are not backward compatible starting from next release.

You are confusing node focus (old selection, remember it was disappearing) and node selection (highlighting, new way). Focus and Highlight are different things. Highlight is permanent and focus is not.

I can't seem to replicate the whole green issue, what should I do to replicate it, which browser are you testing with?

By default, when a tree is selected (highlighted) whole row gets blue background, this is the default YUI skin which is easy to customize, check out the style selectors;

http://developer.yahoo.com/yui/treeview/#style

Hello Cagatay,

I'm glad to hear that you will create a mirgation guide in the feature releases. My problem was my CSS. I have adjusted it and it's working now (no green color for entire tree). Default YUI behavior with row selection is adjusted in my CSS as well so that I have just label selection. It seems to be nicer for me. For this issue viewtopic.php?f=3&t=2506 I have found a workaround too.

Thanks a lot for your effort.
PrimeFaces 4.x, 5.x, Mojarra 2.2.x, JBoss WildFly, WebSphere, Windows 8.1, IntelliJ IDEA
PrimeFaces Cookbook: http://ova2.github.com/primefaces-cookbook/ PrimeFaces Extensions on GitHub: http://primefaces-extensions.github.com/


Posts: 15080
Location: Cybertron

Glad to hear you migrated to new tree Oleg.
PrimeFaces Lead


Return to General

cron