From jira-events at lists.jboss.org Wed May 28 06:23:49 2008 Content-Type: multipart/mixed; boundary="===============7574716207753419932==" MIME-Version: 1.0 From: martin bischoff (JIRA) To: richfaces-issues at lists.jboss.org Subject: [richfaces-issues] [JBoss JIRA] Created: (RF-3569) possible performance issue Date: Wed, 28 May 2008 06:23:49 -0400 Message-ID: <25135648.1211970229264.JavaMail.jira@cloud.prod.atl2.jboss.com> --===============7574716207753419932== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable possible performance issue = --------------------------------------- Key: RF-3569 URL: http://jira.jboss.com/jira/browse/RF-3569 Project: RichFaces Issue Type: Quality Risk Affects Versions: 3.2.0 Reporter: martin bischoff Fix For: 3.2.0.SR1 i've got an quite simple tree with "just" 50 elements =C3=83=C2=83=C3=82=C2= =A1 200 childs -> 10.000 nodes every node gots: - some little text - image for a checkbox via h:graphicImage - a4j:support for listenersupport at the image expanding/collapsing nodes and checking the checkboxes takes a lot of time.= .. jprofiler tells me that most of the time is spend by domparsing. i dont kno= w if i handle the tree as intended. here is some code: JSP [code] <%@ taglib uri=3D"http://richfaces.org/a4j" prefix=3D"a4j"%> <%@ taglib uri=3D"http://richfaces.org/rich" prefix=3D"rich"%> <%@ taglib uri=3D"http://java.sun.com/jsf/html" prefix=3D"h"%> <%@ taglib uri=3D"http://java.sun.com/jsf/core" prefix=3D"f"%> tree = = = [/code] TreeBean: [code]package my_tree; import java.io.IOException; import java.io.InputStream; import java.util.Properties; import javax.faces.FacesException; import javax.faces.context.ExternalContext; import javax.faces.context.FacesContext; import javax.faces.event.AbortProcessingException; import org.richfaces.component.state.TreeState; import org.richfaces.event.NodeSelectedEvent; public class TreeBean { private TreeNode rootNode =3D null; private TreeNode[] rootNodes =3D null; private TreeState treeState; private static final String DATA_PATH =3D "/res/tree/simple-tree-data.prop= erties"; public TreeNode getRootNode() { if (rootNode =3D=3D null) { loadTree(); } return rootNode; } public void setRootNode(TreeNode rootNode) { this.rootNode =3D rootNode; } public TreeNode[] getRootNodes() { if (rootNodes =3D=3D null) { rootNodes =3D this.getRootNode().getChildren(); } return rootNodes; } public void setRootNodes(TreeNode[] rootNodes) { this.rootNodes =3D rootNodes; } public TreeState getTreeState() { return treeState; } public void setTreeState(TreeState treeState) { this.treeState =3D treeState; } private void addNodes(String path, TreeNode node, Properties properties) { boolean end =3D false; int counter =3D 1; while (!end) { String key =3D path !=3D null ? path + '.' + counter : String .valueOf(counter); String value =3D properties.getProperty(key); if (value !=3D null) { TreeNode newNode =3D new TreeNode(value); newNode.setParent(node); node.addNode(newNode); addNodes(key, newNode, properties); counter++; } else { end =3D true; } } } private void loadTree() { System.out.println("TreeBean -> loadTree()"); FacesContext facesContext =3D FacesContext.getCurrentInstance(); ExternalContext externalContext =3D facesContext.getExternalContext(); InputStream dataStream =3D externalContext.getResourceAsStream(DATA_PATH); try { Properties properties =3D new Properties(); properties.load(dataStream); rootNode =3D new TreeNode("root"); addNodes(null, rootNode, properties); // manual tree extension TreeNode dummy =3D new TreeNode("Sichtlinie"); int count =3D 0; for (int i =3D 1; i <=3D 50; i++) { count++; TreeNode node =3D new TreeNode("i" + i); for (int j =3D 1; j <=3D 200; j++) { count++; if (count % 1000 =3D=3D 0) { System.out.println(count); } TreeNode child =3D new TreeNode("j" + j); child.setParent(node); node.addNode(child); } node.setParent(dummy); dummy.addNode(node); } rootNode.addNode(dummy); } catch (IOException e) { e.printStackTrace(); throw new FacesException(e.getMessage(), e); } finally { if (dataStream !=3D null) { try { dataStream.close(); } catch (IOException e) { e.printStackTrace(); externalContext.log(e.getMessage(), e); } } } } public void processSelection(NodeSelectedEvent arg0) throws AbortProcessingException { System.out.println("SimpleTreeBean -> processSelection fired by " + arg0.getComponent().getId()); }[/code] TreeNode: [code]package my_tree; import javax.faces.event.ActionEvent; import org.richfaces.model.TreeNodeImpl; public class TreeNode{ private String value; private String state; private TreeNode parent; private TreeNode[] children; = public TreeNode(String value) { this.value =3D value; this.state =3D ""; } public synchronized void addNode(TreeNode newChild) { System.out.println("addNode("+newChild.getValue()+")"); if (this.children =3D=3D null) { TreeNode[] merged =3D new TreeNode[1]; merged[0] =3D newChild; this.children =3D merged; } else { TreeNode[] merged =3D new TreeNode[this.children.length + 1]; int i; for (i =3D 0; i < this.children.length; i++) { merged[i] =3D this.children[i]; } merged[merged.length - 1] =3D newChild; this.children =3D merged; } } public synchronized void addNodes(TreeNode[] newChildren) { System.out.println("addNodeS("+newChildren.length+")"); TreeNode[] merged =3D new TreeNode[newChildren.length + this.children.length]; int i; for (i =3D 0; i <=3D this.children.length; i++) { merged[i] =3D this.children[i]; } for (int i2 =3D i; i2 <=3D newChildren.length + i; i2++) { merged[i2] =3D newChildren[i2]; } this.children =3D merged; } public synchronized void removeNodes(TreeNode[] removeChildren) { TreeNode[] splitted =3D new TreeNode[this.children.length - removeChildren.length]; int pos =3D 0; for (int i =3D 0; i <=3D this.children.length; i++) { boolean contains =3D false; for (int j =3D 0; j <=3D removeChildren.length; j++) { if (this.children[i] =3D=3D removeChildren[j]) { contains =3D true; } } if (contains =3D=3D false) { splitted[pos] =3D this.children[i]; pos++; } } } public String checkSibling(){ //System.out.println("checkSibling() of "+this.value); if(this.children!=3Dnull){ String state =3D null; int checked =3D 0; int sub =3D 0; int i; = TreeNode[] siblings =3D this.children; for (i =3D 0; i < siblings.length; i++) { = TreeNode treeNode =3D siblings[i]; //System.out.println("\t"+treeNode.getValue()+" - "+treeNode.getState()= ); if(!treeNode.getState().equals("")){ if(treeNode.getState().equals("checked")){ checked++; } else if(treeNode.getState().equals("sub")){ sub++; } } = } = if(checked =3D=3D i){ state =3D "checked"; } else if(sub > 0 || checked > 0) { state =3D "sub"; } else { state =3D ""; } //System.out.println("siblings: "+i+" (checked: "+checked+" sub: "+sub+"= ) -> "+state); return state; } else { return ""; } } = public void setChildsChecked(TreeNode node){ //System.out.println("TreeNode -> setChildsChecked of "+node.getValue()); if(node.getChildren()!=3Dnull){ TreeNode[] children =3D node.getChildren(); for (int i =3D 0; i < children.length; i++) { TreeNode treeNode =3D children[i]; treeNode.setState("checked"); setChildsChecked(treeNode); } } } = public void setChildsUnchecked(TreeNode node){ //System.out.println("TreeNode -> setChildsUnchecked of "+node.getValue()= ); if(node.getChildren()!=3Dnull){ TreeNode[] children =3D node.getChildren(); for (int i =3D 0; i < children.length; i++) { TreeNode treeNode =3D children[i]; treeNode.setState(""); setChildsUnchecked(treeNode); } } } public void setParentsState(TreeNode node){ System.out.println("TreeNode -> setParentsState of "+node.getValue()); node.setState(node.checkSibling()); if(node.getParent()!=3Dnull){ setParentsState(node.getParent()); } } = = public void actionListener(ActionEvent ae){ //System.out.println("TreeNode -> nodeListener fired by "+ae.getComponent= ().getId()); if(this.state =3D=3D "checked"){ this.state =3D ""; setChildsUnchecked(this); } else { this.state =3D "checked"; setChildsChecked(this); } if(this.parent!=3Dnull){ setParentsState(this.parent); } = } = = public String getValue() { return value; } public void setValue(String value) { this.value =3D value; } public TreeNode[] getChildren() { return children; } public void setChildren(TreeNode[] children) { this.children =3D children; } = = public TreeNode getParent() { if(parent=3D=3Dnull){ return null; } else { return parent; } } public void setParent(TreeNode parent) { this.parent =3D parent; } public String getState() { return state; } public void setState(String state) { this.state =3D state; } } [/code] -- = This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: htt= p://jira.jboss.com/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira = --===============7574716207753419932==-- From jira-events at lists.jboss.org Wed May 28 08:17:49 2008 Content-Type: multipart/mixed; boundary="===============8878621751757431074==" MIME-Version: 1.0 From: Aleksej Yanul (JIRA) To: richfaces-issues at lists.jboss.org Subject: [richfaces-issues] [JBoss JIRA] Assigned: (RF-3569) possible performance issue Date: Wed, 28 May 2008 08:17:49 -0400 Message-ID: <30769707.1211977069413.JavaMail.jira@cloud.prod.atl2.jboss.com> In-Reply-To: 25135648.1211970229264.JavaMail.jira@cloud.prod.atl2.jboss.com --===============8878621751757431074== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable [ http://jira.jboss.com/jira/browse/RF-3569?page=3Dall ] Aleksej Yanul reassigned RF-3569: --------------------------------- Assignee: Nick Belaevski > possible performance issue = > --------------------------------------- > > Key: RF-3569 > URL: http://jira.jboss.com/jira/browse/RF-3569 > Project: RichFaces > Issue Type: Quality Risk > Affects Versions: 3.2.0 > Reporter: martin bischoff > Assigned To: Nick Belaevski > Fix For: 3.2.0.SR1 > > > i've got an quite simple tree with "just" 50 elements =C3=83=C2=83=C3=82= =C2=A1 200 childs -> 10.000 nodes > every node gots: > - some little text > - image for a checkbox via h:graphicImage > - a4j:support for listenersupport at the image > expanding/collapsing nodes and checking the checkboxes takes a lot of tim= e... > jprofiler tells me that most of the time is spend by domparsing. i dont k= now if i handle the tree as intended. here is some code: > JSP > [code] > <%@ taglib uri=3D"http://richfaces.org/a4j" prefix=3D"a4j"%> > <%@ taglib uri=3D"http://richfaces.org/rich" prefix=3D"rich"%> > <%@ taglib uri=3D"http://java.sun.com/jsf/html" prefix=3D"h"%> > <%@ taglib uri=3D"http://java.sun.com/jsf/core" prefix=3D"f"%> > > > tree > > > > > > > > > > > > > > = > > > > > > = > > > = > > > > > > > [/code] > TreeBean: > [code]package my_tree; > import java.io.IOException; > import java.io.InputStream; > import java.util.Properties; > import javax.faces.FacesException; > import javax.faces.context.ExternalContext; > import javax.faces.context.FacesContext; > import javax.faces.event.AbortProcessingException; > import org.richfaces.component.state.TreeState; > import org.richfaces.event.NodeSelectedEvent; > public class TreeBean { > private TreeNode rootNode =3D null; > private TreeNode[] rootNodes =3D null; > private TreeState treeState; > private static final String DATA_PATH =3D "/res/tree/simple-tree-data.pr= operties"; > public TreeNode getRootNode() { > if (rootNode =3D=3D null) { > loadTree(); > } > return rootNode; > } > public void setRootNode(TreeNode rootNode) { > this.rootNode =3D rootNode; > } > public TreeNode[] getRootNodes() { > if (rootNodes =3D=3D null) { > rootNodes =3D this.getRootNode().getChildren(); > } > return rootNodes; > } > public void setRootNodes(TreeNode[] rootNodes) { > this.rootNodes =3D rootNodes; > } > public TreeState getTreeState() { > return treeState; > } > public void setTreeState(TreeState treeState) { > this.treeState =3D treeState; > } > private void addNodes(String path, TreeNode node, Properties properties)= { > boolean end =3D false; > int counter =3D 1; > while (!end) { > String key =3D path !=3D null ? path + '.' + counter : String > .valueOf(counter); > String value =3D properties.getProperty(key); > if (value !=3D null) { > TreeNode newNode =3D new TreeNode(value); > newNode.setParent(node); > node.addNode(newNode); > addNodes(key, newNode, properties); > counter++; > } else { > end =3D true; > } > } > } > private void loadTree() { > System.out.println("TreeBean -> loadTree()"); > FacesContext facesContext =3D FacesContext.getCurrentInstance(); > ExternalContext externalContext =3D facesContext.getExternalContext(); > InputStream dataStream =3D externalContext.getResourceAsStream(DATA_PAT= H); > try { > Properties properties =3D new Properties(); > properties.load(dataStream); > rootNode =3D new TreeNode("root"); > addNodes(null, rootNode, properties); > // manual tree extension > TreeNode dummy =3D new TreeNode("Sichtlinie"); > int count =3D 0; > for (int i =3D 1; i <=3D 50; i++) { > count++; > TreeNode node =3D new TreeNode("i" + i); > for (int j =3D 1; j <=3D 200; j++) { > count++; > if (count % 1000 =3D=3D 0) { > System.out.println(count); > } > TreeNode child =3D new TreeNode("j" + j); > child.setParent(node); > node.addNode(child); > } > node.setParent(dummy); > dummy.addNode(node); > } > rootNode.addNode(dummy); > } catch (IOException e) { > e.printStackTrace(); > throw new FacesException(e.getMessage(), e); > } finally { > if (dataStream !=3D null) { > try { > dataStream.close(); > } catch (IOException e) { > e.printStackTrace(); > externalContext.log(e.getMessage(), e); > } > } > } > } > public void processSelection(NodeSelectedEvent arg0) > throws AbortProcessingException { > System.out.println("SimpleTreeBean -> processSelection fired by " > + arg0.getComponent().getId()); > }[/code] > TreeNode: > [code]package my_tree; > import javax.faces.event.ActionEvent; > import org.richfaces.model.TreeNodeImpl; > public class TreeNode{ > private String value; > private String state; > private TreeNode parent; > private TreeNode[] children; > = > public TreeNode(String value) { > this.value =3D value; > this.state =3D ""; > } > public synchronized void addNode(TreeNode newChild) { > System.out.println("addNode("+newChild.getValue()+")"); > if (this.children =3D=3D null) { > TreeNode[] merged =3D new TreeNode[1]; > merged[0] =3D newChild; > this.children =3D merged; > } else { > TreeNode[] merged =3D new TreeNode[this.children.length + 1]; > int i; > for (i =3D 0; i < this.children.length; i++) { > merged[i] =3D this.children[i]; > } > merged[merged.length - 1] =3D newChild; > this.children =3D merged; > } > } > public synchronized void addNodes(TreeNode[] newChildren) { > System.out.println("addNodeS("+newChildren.length+")"); > TreeNode[] merged =3D new TreeNode[newChildren.length > + this.children.length]; > int i; > for (i =3D 0; i <=3D this.children.length; i++) { > merged[i] =3D this.children[i]; > } > for (int i2 =3D i; i2 <=3D newChildren.length + i; i2++) { > merged[i2] =3D newChildren[i2]; > } > this.children =3D merged; > } > public synchronized void removeNodes(TreeNode[] removeChildren) { > TreeNode[] splitted =3D new TreeNode[this.children.length > - removeChildren.length]; > int pos =3D 0; > for (int i =3D 0; i <=3D this.children.length; i++) { > boolean contains =3D false; > for (int j =3D 0; j <=3D removeChildren.length; j++) { > if (this.children[i] =3D=3D removeChildren[j]) { > contains =3D true; > } > } > if (contains =3D=3D false) { > splitted[pos] =3D this.children[i]; > pos++; > } > } > } > public String checkSibling(){ > //System.out.println("checkSibling() of "+this.value); > if(this.children!=3Dnull){ > String state =3D null; > int checked =3D 0; > int sub =3D 0; > int i; = > TreeNode[] siblings =3D this.children; > for (i =3D 0; i < siblings.length; i++) { > = > TreeNode treeNode =3D siblings[i]; > //System.out.println("\t"+treeNode.getValue()+" - "+treeNode.getState= ()); > if(!treeNode.getState().equals("")){ > if(treeNode.getState().equals("checked")){ > checked++; > } else if(treeNode.getState().equals("sub")){ > sub++; > } > } > = > } > = > if(checked =3D=3D i){ > state =3D "checked"; > } else if(sub > 0 || checked > 0) { > state =3D "sub"; > } else { > state =3D ""; > } > //System.out.println("siblings: "+i+" (checked: "+checked+" sub: "+sub= +") -> "+state); > return state; > } else { > return ""; > } > } > = > public void setChildsChecked(TreeNode node){ > //System.out.println("TreeNode -> setChildsChecked of "+node.getValue()= ); > if(node.getChildren()!=3Dnull){ > TreeNode[] children =3D node.getChildren(); > for (int i =3D 0; i < children.length; i++) { > TreeNode treeNode =3D children[i]; > treeNode.setState("checked"); > setChildsChecked(treeNode); > } > } > } > = > public void setChildsUnchecked(TreeNode node){ > //System.out.println("TreeNode -> setChildsUnchecked of "+node.getValue= ()); > if(node.getChildren()!=3Dnull){ > TreeNode[] children =3D node.getChildren(); > for (int i =3D 0; i < children.length; i++) { > TreeNode treeNode =3D children[i]; > treeNode.setState(""); > setChildsUnchecked(treeNode); > } > } > } > public void setParentsState(TreeNode node){ > System.out.println("TreeNode -> setParentsState of "+node.getValue()); > node.setState(node.checkSibling()); > if(node.getParent()!=3Dnull){ > setParentsState(node.getParent()); > } > } = > = > public void actionListener(ActionEvent ae){ > //System.out.println("TreeNode -> nodeListener fired by "+ae.getCompone= nt().getId()); > if(this.state =3D=3D "checked"){ > this.state =3D ""; > setChildsUnchecked(this); > } else { > this.state =3D "checked"; > setChildsChecked(this); > } > if(this.parent!=3Dnull){ > setParentsState(this.parent); > } > = > } = > = > public String getValue() { > return value; > } > public void setValue(String value) { > this.value =3D value; > } > public TreeNode[] getChildren() { > return children; > } > public void setChildren(TreeNode[] children) { > this.children =3D children; > } > = > = > public TreeNode getParent() { > if(parent=3D=3Dnull){ > return null; > } else { > return parent; > } > } > public void setParent(TreeNode parent) { > this.parent =3D parent; > } > public String getState() { > return state; > } > public void setState(String state) { > this.state =3D state; > } > } > [/code] -- = This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: htt= p://jira.jboss.com/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira = --===============8878621751757431074==-- From jira-events at lists.jboss.org Wed May 28 08:54:49 2008 Content-Type: multipart/mixed; boundary="===============6254427611134692333==" MIME-Version: 1.0 From: Ilya Shaikovsky (JIRA) To: richfaces-issues at lists.jboss.org Subject: [richfaces-issues] [JBoss JIRA] Updated: (RF-3569) possible performance issue Date: Wed, 28 May 2008 08:54:49 -0400 Message-ID: <2220494.1211979289405.JavaMail.jira@cloud.prod.atl2.jboss.com> In-Reply-To: 25135648.1211970229264.JavaMail.jira@cloud.prod.atl2.jboss.com --===============6254427611134692333== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable [ http://jira.jboss.com/jira/browse/RF-3569?page=3Dall ] Ilya Shaikovsky updated RF-3569: -------------------------------- Fix Version/s: (was: 3.2.0.SR1) Description: = i've got an quite simple tree with "just" 50 elements =C3=83?=C3=82=C2=A1 2= 00 childs -> 10.000 nodes every node gots: - some little text - image for a checkbox via h:graphicImage - a4j:support for listenersupport at the image expanding/collapsing nodes and checking the checkboxes takes a lot of time.= .. jprofiler tells me that most of the time is spend by domparsing. i dont kno= w if i handle the tree as intended. here is some code: JSP [code] <%@ taglib uri=3D"http://richfaces.org/a4j" prefix=3D"a4j"%> <%@ taglib uri=3D"http://richfaces.org/rich" prefix=3D"rich"%> <%@ taglib uri=3D"http://java.sun.com/jsf/html" prefix=3D"h"%> <%@ taglib uri=3D"http://java.sun.com/jsf/core" prefix=3D"f"%> tree = = = [/code] TreeBean: [code]package my_tree; import java.io.IOException; import java.io.InputStream; import java.util.Properties; import javax.faces.FacesException; import javax.faces.context.ExternalContext; import javax.faces.context.FacesContext; import javax.faces.event.AbortProcessingException; import org.richfaces.component.state.TreeState; import org.richfaces.event.NodeSelectedEvent; public class TreeBean { private TreeNode rootNode =3D null; private TreeNode[] rootNodes =3D null; private TreeState treeState; private static final String DATA_PATH =3D "/res/tree/simple-tree-data.prop= erties"; public TreeNode getRootNode() { if (rootNode =3D=3D null) { loadTree(); } return rootNode; } public void setRootNode(TreeNode rootNode) { this.rootNode =3D rootNode; } public TreeNode[] getRootNodes() { if (rootNodes =3D=3D null) { rootNodes =3D this.getRootNode().getChildren(); } return rootNodes; } public void setRootNodes(TreeNode[] rootNodes) { this.rootNodes =3D rootNodes; } public TreeState getTreeState() { return treeState; } public void setTreeState(TreeState treeState) { this.treeState =3D treeState; } private void addNodes(String path, TreeNode node, Properties properties) { boolean end =3D false; int counter =3D 1; while (!end) { String key =3D path !=3D null ? path + '.' + counter : String .valueOf(counter); String value =3D properties.getProperty(key); if (value !=3D null) { TreeNode newNode =3D new TreeNode(value); newNode.setParent(node); node.addNode(newNode); addNodes(key, newNode, properties); counter++; } else { end =3D true; } } } private void loadTree() { System.out.println("TreeBean -> loadTree()"); FacesContext facesContext =3D FacesContext.getCurrentInstance(); ExternalContext externalContext =3D facesContext.getExternalContext(); InputStream dataStream =3D externalContext.getResourceAsStream(DATA_PATH); try { Properties properties =3D new Properties(); properties.load(dataStream); rootNode =3D new TreeNode("root"); addNodes(null, rootNode, properties); // manual tree extension TreeNode dummy =3D new TreeNode("Sichtlinie"); int count =3D 0; for (int i =3D 1; i <=3D 50; i++) { count++; TreeNode node =3D new TreeNode("i" + i); for (int j =3D 1; j <=3D 200; j++) { count++; if (count % 1000 =3D=3D 0) { System.out.println(count); } TreeNode child =3D new TreeNode("j" + j); child.setParent(node); node.addNode(child); } node.setParent(dummy); dummy.addNode(node); } rootNode.addNode(dummy); } catch (IOException e) { e.printStackTrace(); throw new FacesException(e.getMessage(), e); } finally { if (dataStream !=3D null) { try { dataStream.close(); } catch (IOException e) { e.printStackTrace(); externalContext.log(e.getMessage(), e); } } } } public void processSelection(NodeSelectedEvent arg0) throws AbortProcessingException { System.out.println("SimpleTreeBean -> processSelection fired by " + arg0.getComponent().getId()); }[/code] TreeNode: [code]package my_tree; import javax.faces.event.ActionEvent; import org.richfaces.model.TreeNodeImpl; public class TreeNode{ private String value; private String state; private TreeNode parent; private TreeNode[] children; = public TreeNode(String value) { this.value =3D value; this.state =3D ""; } public synchronized void addNode(TreeNode newChild) { System.out.println("addNode("+newChild.getValue()+")"); if (this.children =3D=3D null) { TreeNode[] merged =3D new TreeNode[1]; merged[0] =3D newChild; this.children =3D merged; } else { TreeNode[] merged =3D new TreeNode[this.children.length + 1]; int i; for (i =3D 0; i < this.children.length; i++) { merged[i] =3D this.children[i]; } merged[merged.length - 1] =3D newChild; this.children =3D merged; } } public synchronized void addNodes(TreeNode[] newChildren) { System.out.println("addNodeS("+newChildren.length+")"); TreeNode[] merged =3D new TreeNode[newChildren.length + this.children.length]; int i; for (i =3D 0; i <=3D this.children.length; i++) { merged[i] =3D this.children[i]; } for (int i2 =3D i; i2 <=3D newChildren.length + i; i2++) { merged[i2] =3D newChildren[i2]; } this.children =3D merged; } public synchronized void removeNodes(TreeNode[] removeChildren) { TreeNode[] splitted =3D new TreeNode[this.children.length - removeChildren.length]; int pos =3D 0; for (int i =3D 0; i <=3D this.children.length; i++) { boolean contains =3D false; for (int j =3D 0; j <=3D removeChildren.length; j++) { if (this.children[i] =3D=3D removeChildren[j]) { contains =3D true; } } if (contains =3D=3D false) { splitted[pos] =3D this.children[i]; pos++; } } } public String checkSibling(){ //System.out.println("checkSibling() of "+this.value); if(this.children!=3Dnull){ String state =3D null; int checked =3D 0; int sub =3D 0; int i; = TreeNode[] siblings =3D this.children; for (i =3D 0; i < siblings.length; i++) { = TreeNode treeNode =3D siblings[i]; //System.out.println("\t"+treeNode.getValue()+" - "+treeNode.getState()= ); if(!treeNode.getState().equals("")){ if(treeNode.getState().equals("checked")){ checked++; } else if(treeNode.getState().equals("sub")){ sub++; } } = } = if(checked =3D=3D i){ state =3D "checked"; } else if(sub > 0 || checked > 0) { state =3D "sub"; } else { state =3D ""; } //System.out.println("siblings: "+i+" (checked: "+checked+" sub: "+sub+"= ) -> "+state); return state; } else { return ""; } } = public void setChildsChecked(TreeNode node){ //System.out.println("TreeNode -> setChildsChecked of "+node.getValue()); if(node.getChildren()!=3Dnull){ TreeNode[] children =3D node.getChildren(); for (int i =3D 0; i < children.length; i++) { TreeNode treeNode =3D children[i]; treeNode.setState("checked"); setChildsChecked(treeNode); } } } = public void setChildsUnchecked(TreeNode node){ //System.out.println("TreeNode -> setChildsUnchecked of "+node.getValue()= ); if(node.getChildren()!=3Dnull){ TreeNode[] children =3D node.getChildren(); for (int i =3D 0; i < children.length; i++) { TreeNode treeNode =3D children[i]; treeNode.setState(""); setChildsUnchecked(treeNode); } } } public void setParentsState(TreeNode node){ System.out.println("TreeNode -> setParentsState of "+node.getValue()); node.setState(node.checkSibling()); if(node.getParent()!=3Dnull){ setParentsState(node.getParent()); } } = = public void actionListener(ActionEvent ae){ //System.out.println("TreeNode -> nodeListener fired by "+ae.getComponent= ().getId()); if(this.state =3D=3D "checked"){ this.state =3D ""; setChildsUnchecked(this); } else { this.state =3D "checked"; setChildsChecked(this); } if(this.parent!=3Dnull){ setParentsState(this.parent); } = } = = public String getValue() { return value; } public void setValue(String value) { this.value =3D value; } public TreeNode[] getChildren() { return children; } public void setChildren(TreeNode[] children) { this.children =3D children; } = = public TreeNode getParent() { if(parent=3D=3Dnull){ return null; } else { return parent; } } public void setParent(TreeNode parent) { this.parent =3D parent; } public String getState() { return state; } public void setState(String state) { this.state =3D state; } } [/code] was: i've got an quite simple tree with "just" 50 elements =C3=83=C2=83=C3=82=C2= =A1 200 childs -> 10.000 nodes every node gots: - some little text - image for a checkbox via h:graphicImage - a4j:support for listenersupport at the image expanding/collapsing nodes and checking the checkboxes takes a lot of time.= .. jprofiler tells me that most of the time is spend by domparsing. i dont kno= w if i handle the tree as intended. here is some code: JSP [code] <%@ taglib uri=3D"http://richfaces.org/a4j" prefix=3D"a4j"%> <%@ taglib uri=3D"http://richfaces.org/rich" prefix=3D"rich"%> <%@ taglib uri=3D"http://java.sun.com/jsf/html" prefix=3D"h"%> <%@ taglib uri=3D"http://java.sun.com/jsf/core" prefix=3D"f"%> tree = = = [/code] TreeBean: [code]package my_tree; import java.io.IOException; import java.io.InputStream; import java.util.Properties; import javax.faces.FacesException; import javax.faces.context.ExternalContext; import javax.faces.context.FacesContext; import javax.faces.event.AbortProcessingException; import org.richfaces.component.state.TreeState; import org.richfaces.event.NodeSelectedEvent; public class TreeBean { private TreeNode rootNode =3D null; private TreeNode[] rootNodes =3D null; private TreeState treeState; private static final String DATA_PATH =3D "/res/tree/simple-tree-data.prop= erties"; public TreeNode getRootNode() { if (rootNode =3D=3D null) { loadTree(); } return rootNode; } public void setRootNode(TreeNode rootNode) { this.rootNode =3D rootNode; } public TreeNode[] getRootNodes() { if (rootNodes =3D=3D null) { rootNodes =3D this.getRootNode().getChildren(); } return rootNodes; } public void setRootNodes(TreeNode[] rootNodes) { this.rootNodes =3D rootNodes; } public TreeState getTreeState() { return treeState; } public void setTreeState(TreeState treeState) { this.treeState =3D treeState; } private void addNodes(String path, TreeNode node, Properties properties) { boolean end =3D false; int counter =3D 1; while (!end) { String key =3D path !=3D null ? path + '.' + counter : String .valueOf(counter); String value =3D properties.getProperty(key); if (value !=3D null) { TreeNode newNode =3D new TreeNode(value); newNode.setParent(node); node.addNode(newNode); addNodes(key, newNode, properties); counter++; } else { end =3D true; } } } private void loadTree() { System.out.println("TreeBean -> loadTree()"); FacesContext facesContext =3D FacesContext.getCurrentInstance(); ExternalContext externalContext =3D facesContext.getExternalContext(); InputStream dataStream =3D externalContext.getResourceAsStream(DATA_PATH); try { Properties properties =3D new Properties(); properties.load(dataStream); rootNode =3D new TreeNode("root"); addNodes(null, rootNode, properties); // manual tree extension TreeNode dummy =3D new TreeNode("Sichtlinie"); int count =3D 0; for (int i =3D 1; i <=3D 50; i++) { count++; TreeNode node =3D new TreeNode("i" + i); for (int j =3D 1; j <=3D 200; j++) { count++; if (count % 1000 =3D=3D 0) { System.out.println(count); } TreeNode child =3D new TreeNode("j" + j); child.setParent(node); node.addNode(child); } node.setParent(dummy); dummy.addNode(node); } rootNode.addNode(dummy); } catch (IOException e) { e.printStackTrace(); throw new FacesException(e.getMessage(), e); } finally { if (dataStream !=3D null) { try { dataStream.close(); } catch (IOException e) { e.printStackTrace(); externalContext.log(e.getMessage(), e); } } } } public void processSelection(NodeSelectedEvent arg0) throws AbortProcessingException { System.out.println("SimpleTreeBean -> processSelection fired by " + arg0.getComponent().getId()); }[/code] TreeNode: [code]package my_tree; import javax.faces.event.ActionEvent; import org.richfaces.model.TreeNodeImpl; public class TreeNode{ private String value; private String state; private TreeNode parent; private TreeNode[] children; = public TreeNode(String value) { this.value =3D value; this.state =3D ""; } public synchronized void addNode(TreeNode newChild) { System.out.println("addNode("+newChild.getValue()+")"); if (this.children =3D=3D null) { TreeNode[] merged =3D new TreeNode[1]; merged[0] =3D newChild; this.children =3D merged; } else { TreeNode[] merged =3D new TreeNode[this.children.length + 1]; int i; for (i =3D 0; i < this.children.length; i++) { merged[i] =3D this.children[i]; } merged[merged.length - 1] =3D newChild; this.children =3D merged; } } public synchronized void addNodes(TreeNode[] newChildren) { System.out.println("addNodeS("+newChildren.length+")"); TreeNode[] merged =3D new TreeNode[newChildren.length + this.children.length]; int i; for (i =3D 0; i <=3D this.children.length; i++) { merged[i] =3D this.children[i]; } for (int i2 =3D i; i2 <=3D newChildren.length + i; i2++) { merged[i2] =3D newChildren[i2]; } this.children =3D merged; } public synchronized void removeNodes(TreeNode[] removeChildren) { TreeNode[] splitted =3D new TreeNode[this.children.length - removeChildren.length]; int pos =3D 0; for (int i =3D 0; i <=3D this.children.length; i++) { boolean contains =3D false; for (int j =3D 0; j <=3D removeChildren.length; j++) { if (this.children[i] =3D=3D removeChildren[j]) { contains =3D true; } } if (contains =3D=3D false) { splitted[pos] =3D this.children[i]; pos++; } } } public String checkSibling(){ //System.out.println("checkSibling() of "+this.value); if(this.children!=3Dnull){ String state =3D null; int checked =3D 0; int sub =3D 0; int i; = TreeNode[] siblings =3D this.children; for (i =3D 0; i < siblings.length; i++) { = TreeNode treeNode =3D siblings[i]; //System.out.println("\t"+treeNode.getValue()+" - "+treeNode.getState()= ); if(!treeNode.getState().equals("")){ if(treeNode.getState().equals("checked")){ checked++; } else if(treeNode.getState().equals("sub")){ sub++; } } = } = if(checked =3D=3D i){ state =3D "checked"; } else if(sub > 0 || checked > 0) { state =3D "sub"; } else { state =3D ""; } //System.out.println("siblings: "+i+" (checked: "+checked+" sub: "+sub+"= ) -> "+state); return state; } else { return ""; } } = public void setChildsChecked(TreeNode node){ //System.out.println("TreeNode -> setChildsChecked of "+node.getValue()); if(node.getChildren()!=3Dnull){ TreeNode[] children =3D node.getChildren(); for (int i =3D 0; i < children.length; i++) { TreeNode treeNode =3D children[i]; treeNode.setState("checked"); setChildsChecked(treeNode); } } } = public void setChildsUnchecked(TreeNode node){ //System.out.println("TreeNode -> setChildsUnchecked of "+node.getValue()= ); if(node.getChildren()!=3Dnull){ TreeNode[] children =3D node.getChildren(); for (int i =3D 0; i < children.length; i++) { TreeNode treeNode =3D children[i]; treeNode.setState(""); setChildsUnchecked(treeNode); } } } public void setParentsState(TreeNode node){ System.out.println("TreeNode -> setParentsState of "+node.getValue()); node.setState(node.checkSibling()); if(node.getParent()!=3Dnull){ setParentsState(node.getParent()); } } = = public void actionListener(ActionEvent ae){ //System.out.println("TreeNode -> nodeListener fired by "+ae.getComponent= ().getId()); if(this.state =3D=3D "checked"){ this.state =3D ""; setChildsUnchecked(this); } else { this.state =3D "checked"; setChildsChecked(this); } if(this.parent!=3Dnull){ setParentsState(this.parent); } = } = = public String getValue() { return value; } public void setValue(String value) { this.value =3D value; } public TreeNode[] getChildren() { return children; } public void setChildren(TreeNode[] children) { this.children =3D children; } = = public TreeNode getParent() { if(parent=3D=3Dnull){ return null; } else { return parent; } } public void setParent(TreeNode parent) { this.parent =3D parent; } public String getState() { return state; } public void setState(String state) { this.state =3D state; } } [/code] > possible performance issue = > --------------------------------------- > > Key: RF-3569 > URL: http://jira.jboss.com/jira/browse/RF-3569 > Project: RichFaces > Issue Type: Quality Risk > Affects Versions: 3.2.0 > Reporter: martin bischoff > Assigned To: Nick Belaevski > > i've got an quite simple tree with "just" 50 elements =C3=83=C6=92=C3=82= =C2=A1 200 childs -> 10.000 nodes > every node gots: > - some little text > - image for a checkbox via h:graphicImage > - a4j:support for listenersupport at the image > expanding/collapsing nodes and checking the checkboxes takes a lot of tim= e... > jprofiler tells me that most of the time is spend by domparsing. i dont k= now if i handle the tree as intended. here is some code: > JSP > [code] > <%@ taglib uri=3D"http://richfaces.org/a4j" prefix=3D"a4j"%> > <%@ taglib uri=3D"http://richfaces.org/rich" prefix=3D"rich"%> > <%@ taglib uri=3D"http://java.sun.com/jsf/html" prefix=3D"h"%> > <%@ taglib uri=3D"http://java.sun.com/jsf/core" prefix=3D"f"%> > > > tree > > > > > > > > > > > > > > = > > > > > > = > > > = > > > > > > > [/code] > TreeBean: > [code]package my_tree; > import java.io.IOException; > import java.io.InputStream; > import java.util.Properties; > import javax.faces.FacesException; > import javax.faces.context.ExternalContext; > import javax.faces.context.FacesContext; > import javax.faces.event.AbortProcessingException; > import org.richfaces.component.state.TreeState; > import org.richfaces.event.NodeSelectedEvent; > public class TreeBean { > private TreeNode rootNode =3D null; > private TreeNode[] rootNodes =3D null; > private TreeState treeState; > private static final String DATA_PATH =3D "/res/tree/simple-tree-data.pr= operties"; > public TreeNode getRootNode() { > if (rootNode =3D=3D null) { > loadTree(); > } > return rootNode; > } > public void setRootNode(TreeNode rootNode) { > this.rootNode =3D rootNode; > } > public TreeNode[] getRootNodes() { > if (rootNodes =3D=3D null) { > rootNodes =3D this.getRootNode().getChildren(); > } > return rootNodes; > } > public void setRootNodes(TreeNode[] rootNodes) { > this.rootNodes =3D rootNodes; > } > public TreeState getTreeState() { > return treeState; > } > public void setTreeState(TreeState treeState) { > this.treeState =3D treeState; > } > private void addNodes(String path, TreeNode node, Properties properties)= { > boolean end =3D false; > int counter =3D 1; > while (!end) { > String key =3D path !=3D null ? path + '.' + counter : String > .valueOf(counter); > String value =3D properties.getProperty(key); > if (value !=3D null) { > TreeNode newNode =3D new TreeNode(value); > newNode.setParent(node); > node.addNode(newNode); > addNodes(key, newNode, properties); > counter++; > } else { > end =3D true; > } > } > } > private void loadTree() { > System.out.println("TreeBean -> loadTree()"); > FacesContext facesContext =3D FacesContext.getCurrentInstance(); > ExternalContext externalContext =3D facesContext.getExternalContext(); > InputStream dataStream =3D externalContext.getResourceAsStream(DATA_PAT= H); > try { > Properties properties =3D new Properties(); > properties.load(dataStream); > rootNode =3D new TreeNode("root"); > addNodes(null, rootNode, properties); > // manual tree extension > TreeNode dummy =3D new TreeNode("Sichtlinie"); > int count =3D 0; > for (int i =3D 1; i <=3D 50; i++) { > count++; > TreeNode node =3D new TreeNode("i" + i); > for (int j =3D 1; j <=3D 200; j++) { > count++; > if (count % 1000 =3D=3D 0) { > System.out.println(count); > } > TreeNode child =3D new TreeNode("j" + j); > child.setParent(node); > node.addNode(child); > } > node.setParent(dummy); > dummy.addNode(node); > } > rootNode.addNode(dummy); > } catch (IOException e) { > e.printStackTrace(); > throw new FacesException(e.getMessage(), e); > } finally { > if (dataStream !=3D null) { > try { > dataStream.close(); > } catch (IOException e) { > e.printStackTrace(); > externalContext.log(e.getMessage(), e); > } > } > } > } > public void processSelection(NodeSelectedEvent arg0) > throws AbortProcessingException { > System.out.println("SimpleTreeBean -> processSelection fired by " > + arg0.getComponent().getId()); > }[/code] > TreeNode: > [code]package my_tree; > import javax.faces.event.ActionEvent; > import org.richfaces.model.TreeNodeImpl; > public class TreeNode{ > private String value; > private String state; > private TreeNode parent; > private TreeNode[] children; > = > public TreeNode(String value) { > this.value =3D value; > this.state =3D ""; > } > public synchronized void addNode(TreeNode newChild) { > System.out.println("addNode("+newChild.getValue()+")"); > if (this.children =3D=3D null) { > TreeNode[] merged =3D new TreeNode[1]; > merged[0] =3D newChild; > this.children =3D merged; > } else { > TreeNode[] merged =3D new TreeNode[this.children.length + 1]; > int i; > for (i =3D 0; i < this.children.length; i++) { > merged[i] =3D this.children[i]; > } > merged[merged.length - 1] =3D newChild; > this.children =3D merged; > } > } > public synchronized void addNodes(TreeNode[] newChildren) { > System.out.println("addNodeS("+newChildren.length+")"); > TreeNode[] merged =3D new TreeNode[newChildren.length > + this.children.length]; > int i; > for (i =3D 0; i <=3D this.children.length; i++) { > merged[i] =3D this.children[i]; > } > for (int i2 =3D i; i2 <=3D newChildren.length + i; i2++) { > merged[i2] =3D newChildren[i2]; > } > this.children =3D merged; > } > public synchronized void removeNodes(TreeNode[] removeChildren) { > TreeNode[] splitted =3D new TreeNode[this.children.length > - removeChildren.length]; > int pos =3D 0; > for (int i =3D 0; i <=3D this.children.length; i++) { > boolean contains =3D false; > for (int j =3D 0; j <=3D removeChildren.length; j++) { > if (this.children[i] =3D=3D removeChildren[j]) { > contains =3D true; > } > } > if (contains =3D=3D false) { > splitted[pos] =3D this.children[i]; > pos++; > } > } > } > public String checkSibling(){ > //System.out.println("checkSibling() of "+this.value); > if(this.children!=3Dnull){ > String state =3D null; > int checked =3D 0; > int sub =3D 0; > int i; = > TreeNode[] siblings =3D this.children; > for (i =3D 0; i < siblings.length; i++) { > = > TreeNode treeNode =3D siblings[i]; > //System.out.println("\t"+treeNode.getValue()+" - "+treeNode.getState= ()); > if(!treeNode.getState().equals("")){ > if(treeNode.getState().equals("checked")){ > checked++; > } else if(treeNode.getState().equals("sub")){ > sub++; > } > } > = > } > = > if(checked =3D=3D i){ > state =3D "checked"; > } else if(sub > 0 || checked > 0) { > state =3D "sub"; > } else { > state =3D ""; > } > //System.out.println("siblings: "+i+" (checked: "+checked+" sub: "+sub= +") -> "+state); > return state; > } else { > return ""; > } > } > = > public void setChildsChecked(TreeNode node){ > //System.out.println("TreeNode -> setChildsChecked of "+node.getValue()= ); > if(node.getChildren()!=3Dnull){ > TreeNode[] children =3D node.getChildren(); > for (int i =3D 0; i < children.length; i++) { > TreeNode treeNode =3D children[i]; > treeNode.setState("checked"); > setChildsChecked(treeNode); > } > } > } > = > public void setChildsUnchecked(TreeNode node){ > //System.out.println("TreeNode -> setChildsUnchecked of "+node.getValue= ()); > if(node.getChildren()!=3Dnull){ > TreeNode[] children =3D node.getChildren(); > for (int i =3D 0; i < children.length; i++) { > TreeNode treeNode =3D children[i]; > treeNode.setState(""); > setChildsUnchecked(treeNode); > } > } > } > public void setParentsState(TreeNode node){ > System.out.println("TreeNode -> setParentsState of "+node.getValue()); > node.setState(node.checkSibling()); > if(node.getParent()!=3Dnull){ > setParentsState(node.getParent()); > } > } = > = > public void actionListener(ActionEvent ae){ > //System.out.println("TreeNode -> nodeListener fired by "+ae.getCompone= nt().getId()); > if(this.state =3D=3D "checked"){ > this.state =3D ""; > setChildsUnchecked(this); > } else { > this.state =3D "checked"; > setChildsChecked(this); > } > if(this.parent!=3Dnull){ > setParentsState(this.parent); > } > = > } = > = > public String getValue() { > return value; > } > public void setValue(String value) { > this.value =3D value; > } > public TreeNode[] getChildren() { > return children; > } > public void setChildren(TreeNode[] children) { > this.children =3D children; > } > = > = > public TreeNode getParent() { > if(parent=3D=3Dnull){ > return null; > } else { > return parent; > } > } > public void setParent(TreeNode parent) { > this.parent =3D parent; > } > public String getState() { > return state; > } > public void setState(String state) { > this.state =3D state; > } > } > [/code] -- = This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: htt= p://jira.jboss.com/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira = --===============6254427611134692333==-- From jira-events at lists.jboss.org Wed May 28 15:21:40 2008 Content-Type: multipart/mixed; boundary="===============7140788957545366463==" MIME-Version: 1.0 From: Nick Belaevski (JIRA) To: richfaces-issues at lists.jboss.org Subject: [richfaces-issues] [JBoss JIRA] Updated: (RF-3569) possible performance issue Date: Wed, 28 May 2008 15:21:40 -0400 Message-ID: <8099526.1212002500624.JavaMail.jira@cloud.prod.atl2.jboss.com> In-Reply-To: 25135648.1211970229264.JavaMail.jira@cloud.prod.atl2.jboss.com --===============7140788957545366463== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable [ http://jira.jboss.com/jira/browse/RF-3569?page=3Dall ] Nick Belaevski updated RF-3569: ------------------------------- Fix Version/s: 3.2.2 > possible performance issue = > --------------------------------------- > > Key: RF-3569 > URL: http://jira.jboss.com/jira/browse/RF-3569 > Project: RichFaces > Issue Type: Quality Risk > Affects Versions: 3.2.0 > Reporter: martin bischoff > Assigned To: Nick Belaevski > Fix For: 3.2.2 > > > i've got an quite simple tree with "just" 50 elements =C3=83?=C3=82=C2=A1= 200 childs -> 10.000 nodes > every node gots: > - some little text > - image for a checkbox via h:graphicImage > - a4j:support for listenersupport at the image > expanding/collapsing nodes and checking the checkboxes takes a lot of tim= e... > jprofiler tells me that most of the time is spend by domparsing. i dont k= now if i handle the tree as intended. here is some code: > JSP > [code] > <%@ taglib uri=3D"http://richfaces.org/a4j" prefix=3D"a4j"%> > <%@ taglib uri=3D"http://richfaces.org/rich" prefix=3D"rich"%> > <%@ taglib uri=3D"http://java.sun.com/jsf/html" prefix=3D"h"%> > <%@ taglib uri=3D"http://java.sun.com/jsf/core" prefix=3D"f"%> > > > tree > > > > > > > > > > > > > > = > > > > > > = > > > = > > > > > > > [/code] > TreeBean: > [code]package my_tree; > import java.io.IOException; > import java.io.InputStream; > import java.util.Properties; > import javax.faces.FacesException; > import javax.faces.context.ExternalContext; > import javax.faces.context.FacesContext; > import javax.faces.event.AbortProcessingException; > import org.richfaces.component.state.TreeState; > import org.richfaces.event.NodeSelectedEvent; > public class TreeBean { > private TreeNode rootNode =3D null; > private TreeNode[] rootNodes =3D null; > private TreeState treeState; > private static final String DATA_PATH =3D "/res/tree/simple-tree-data.pr= operties"; > public TreeNode getRootNode() { > if (rootNode =3D=3D null) { > loadTree(); > } > return rootNode; > } > public void setRootNode(TreeNode rootNode) { > this.rootNode =3D rootNode; > } > public TreeNode[] getRootNodes() { > if (rootNodes =3D=3D null) { > rootNodes =3D this.getRootNode().getChildren(); > } > return rootNodes; > } > public void setRootNodes(TreeNode[] rootNodes) { > this.rootNodes =3D rootNodes; > } > public TreeState getTreeState() { > return treeState; > } > public void setTreeState(TreeState treeState) { > this.treeState =3D treeState; > } > private void addNodes(String path, TreeNode node, Properties properties)= { > boolean end =3D false; > int counter =3D 1; > while (!end) { > String key =3D path !=3D null ? path + '.' + counter : String > .valueOf(counter); > String value =3D properties.getProperty(key); > if (value !=3D null) { > TreeNode newNode =3D new TreeNode(value); > newNode.setParent(node); > node.addNode(newNode); > addNodes(key, newNode, properties); > counter++; > } else { > end =3D true; > } > } > } > private void loadTree() { > System.out.println("TreeBean -> loadTree()"); > FacesContext facesContext =3D FacesContext.getCurrentInstance(); > ExternalContext externalContext =3D facesContext.getExternalContext(); > InputStream dataStream =3D externalContext.getResourceAsStream(DATA_PAT= H); > try { > Properties properties =3D new Properties(); > properties.load(dataStream); > rootNode =3D new TreeNode("root"); > addNodes(null, rootNode, properties); > // manual tree extension > TreeNode dummy =3D new TreeNode("Sichtlinie"); > int count =3D 0; > for (int i =3D 1; i <=3D 50; i++) { > count++; > TreeNode node =3D new TreeNode("i" + i); > for (int j =3D 1; j <=3D 200; j++) { > count++; > if (count % 1000 =3D=3D 0) { > System.out.println(count); > } > TreeNode child =3D new TreeNode("j" + j); > child.setParent(node); > node.addNode(child); > } > node.setParent(dummy); > dummy.addNode(node); > } > rootNode.addNode(dummy); > } catch (IOException e) { > e.printStackTrace(); > throw new FacesException(e.getMessage(), e); > } finally { > if (dataStream !=3D null) { > try { > dataStream.close(); > } catch (IOException e) { > e.printStackTrace(); > externalContext.log(e.getMessage(), e); > } > } > } > } > public void processSelection(NodeSelectedEvent arg0) > throws AbortProcessingException { > System.out.println("SimpleTreeBean -> processSelection fired by " > + arg0.getComponent().getId()); > }[/code] > TreeNode: > [code]package my_tree; > import javax.faces.event.ActionEvent; > import org.richfaces.model.TreeNodeImpl; > public class TreeNode{ > private String value; > private String state; > private TreeNode parent; > private TreeNode[] children; > = > public TreeNode(String value) { > this.value =3D value; > this.state =3D ""; > } > public synchronized void addNode(TreeNode newChild) { > System.out.println("addNode("+newChild.getValue()+")"); > if (this.children =3D=3D null) { > TreeNode[] merged =3D new TreeNode[1]; > merged[0] =3D newChild; > this.children =3D merged; > } else { > TreeNode[] merged =3D new TreeNode[this.children.length + 1]; > int i; > for (i =3D 0; i < this.children.length; i++) { > merged[i] =3D this.children[i]; > } > merged[merged.length - 1] =3D newChild; > this.children =3D merged; > } > } > public synchronized void addNodes(TreeNode[] newChildren) { > System.out.println("addNodeS("+newChildren.length+")"); > TreeNode[] merged =3D new TreeNode[newChildren.length > + this.children.length]; > int i; > for (i =3D 0; i <=3D this.children.length; i++) { > merged[i] =3D this.children[i]; > } > for (int i2 =3D i; i2 <=3D newChildren.length + i; i2++) { > merged[i2] =3D newChildren[i2]; > } > this.children =3D merged; > } > public synchronized void removeNodes(TreeNode[] removeChildren) { > TreeNode[] splitted =3D new TreeNode[this.children.length > - removeChildren.length]; > int pos =3D 0; > for (int i =3D 0; i <=3D this.children.length; i++) { > boolean contains =3D false; > for (int j =3D 0; j <=3D removeChildren.length; j++) { > if (this.children[i] =3D=3D removeChildren[j]) { > contains =3D true; > } > } > if (contains =3D=3D false) { > splitted[pos] =3D this.children[i]; > pos++; > } > } > } > public String checkSibling(){ > //System.out.println("checkSibling() of "+this.value); > if(this.children!=3Dnull){ > String state =3D null; > int checked =3D 0; > int sub =3D 0; > int i; = > TreeNode[] siblings =3D this.children; > for (i =3D 0; i < siblings.length; i++) { > = > TreeNode treeNode =3D siblings[i]; > //System.out.println("\t"+treeNode.getValue()+" - "+treeNode.getState= ()); > if(!treeNode.getState().equals("")){ > if(treeNode.getState().equals("checked")){ > checked++; > } else if(treeNode.getState().equals("sub")){ > sub++; > } > } > = > } > = > if(checked =3D=3D i){ > state =3D "checked"; > } else if(sub > 0 || checked > 0) { > state =3D "sub"; > } else { > state =3D ""; > } > //System.out.println("siblings: "+i+" (checked: "+checked+" sub: "+sub= +") -> "+state); > return state; > } else { > return ""; > } > } > = > public void setChildsChecked(TreeNode node){ > //System.out.println("TreeNode -> setChildsChecked of "+node.getValue()= ); > if(node.getChildren()!=3Dnull){ > TreeNode[] children =3D node.getChildren(); > for (int i =3D 0; i < children.length; i++) { > TreeNode treeNode =3D children[i]; > treeNode.setState("checked"); > setChildsChecked(treeNode); > } > } > } > = > public void setChildsUnchecked(TreeNode node){ > //System.out.println("TreeNode -> setChildsUnchecked of "+node.getValue= ()); > if(node.getChildren()!=3Dnull){ > TreeNode[] children =3D node.getChildren(); > for (int i =3D 0; i < children.length; i++) { > TreeNode treeNode =3D children[i]; > treeNode.setState(""); > setChildsUnchecked(treeNode); > } > } > } > public void setParentsState(TreeNode node){ > System.out.println("TreeNode -> setParentsState of "+node.getValue()); > node.setState(node.checkSibling()); > if(node.getParent()!=3Dnull){ > setParentsState(node.getParent()); > } > } = > = > public void actionListener(ActionEvent ae){ > //System.out.println("TreeNode -> nodeListener fired by "+ae.getCompone= nt().getId()); > if(this.state =3D=3D "checked"){ > this.state =3D ""; > setChildsUnchecked(this); > } else { > this.state =3D "checked"; > setChildsChecked(this); > } > if(this.parent!=3Dnull){ > setParentsState(this.parent); > } > = > } = > = > public String getValue() { > return value; > } > public void setValue(String value) { > this.value =3D value; > } > public TreeNode[] getChildren() { > return children; > } > public void setChildren(TreeNode[] children) { > this.children =3D children; > } > = > = > public TreeNode getParent() { > if(parent=3D=3Dnull){ > return null; > } else { > return parent; > } > } > public void setParent(TreeNode parent) { > this.parent =3D parent; > } > public String getState() { > return state; > } > public void setState(String state) { > this.state =3D state; > } > } > [/code] -- = This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: htt= p://jira.jboss.com/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira = --===============7140788957545366463==-- From jira-events at lists.jboss.org Wed Jun 4 04:28:25 2008 Content-Type: multipart/mixed; boundary="===============7886267154228774975==" MIME-Version: 1.0 From: martin bischoff (JIRA) To: richfaces-issues at lists.jboss.org Subject: [richfaces-issues] [JBoss JIRA] Commented: (RF-3569) possible performance issue Date: Wed, 04 Jun 2008 04:28:20 -0400 Message-ID: <10869266.1212568100783.JavaMail.jira@cloud.prod.atl2.jboss.com> In-Reply-To: 25135648.1211970229264.JavaMail.jira@cloud.prod.atl2.jboss.com --===============7886267154228774975== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable [ http://jira.jboss.com/jira/browse/RF-3569?page=3Dcomments#action_1241= 5509 ] = = martin bischoff commented on RF-3569: ------------------------------------- over the last days i adapted the src of the tree and changed the html struc= ture from nested tables to ul-li constructs with a view to implement a rela= tive complex styleguide. = as a result of this, the cpu time allocation measured by jprofiler changed.= here is a small comparision, maybe it helps you. modified tree - ul org.ajax4jsf.webapp.tidy.tidyparser.parsehtmlbytidy 86%: |-org.ajax4jsf.org.wc3.tidy.tidy.parsedom 31% |-org.ajax4jsf.org.wc3.tidy.tidy.pprint 23.5% |-org.wc3.dom.nodelist.getlength 20% |-org.wc3.dom.item 10% org.ajax4jsf.application.ajaxviewhandler.renderview 7.8% orgiginal tree - table org.ajax4jsf.webapp.tidy.tidyparser.parsehtmlbytidy 90%: |-org.ajax4jsf.org.wc3.tidy.tidy.parsedom 45% |-org.ajax4jsf.org.wc3.tidy.tidy.pprint 34.5% |-org.wc3.dom.nodelist.getlength 6.8% |-org.wc3.dom.item 3.6% org.ajax4jsf.application.ajaxviewhandler.renderview 7.6% > possible performance issue = > --------------------------------------- > > Key: RF-3569 > URL: http://jira.jboss.com/jira/browse/RF-3569 > Project: RichFaces > Issue Type: Quality Risk > Affects Versions: 3.2.0 > Reporter: martin bischoff > Assigned To: Nick Belaevski > Fix For: 3.2.2 > > > i've got an quite simple tree with "just" 50 elements =C3=83?=C3=82=C2=A1= 200 childs -> 10.000 nodes > every node gots: > - some little text > - image for a checkbox via h:graphicImage > - a4j:support for listenersupport at the image > expanding/collapsing nodes and checking the checkboxes takes a lot of tim= e... > jprofiler tells me that most of the time is spend by domparsing. i dont k= now if i handle the tree as intended. here is some code: > JSP > [code] > <%@ taglib uri=3D"http://richfaces.org/a4j" prefix=3D"a4j"%> > <%@ taglib uri=3D"http://richfaces.org/rich" prefix=3D"rich"%> > <%@ taglib uri=3D"http://java.sun.com/jsf/html" prefix=3D"h"%> > <%@ taglib uri=3D"http://java.sun.com/jsf/core" prefix=3D"f"%> > > > tree > > > > > > > > > > > > > > = > > > > > > = > > > = > > > > > > > [/code] > TreeBean: > [code]package my_tree; > import java.io.IOException; > import java.io.InputStream; > import java.util.Properties; > import javax.faces.FacesException; > import javax.faces.context.ExternalContext; > import javax.faces.context.FacesContext; > import javax.faces.event.AbortProcessingException; > import org.richfaces.component.state.TreeState; > import org.richfaces.event.NodeSelectedEvent; > public class TreeBean { > private TreeNode rootNode =3D null; > private TreeNode[] rootNodes =3D null; > private TreeState treeState; > private static final String DATA_PATH =3D "/res/tree/simple-tree-data.pr= operties"; > public TreeNode getRootNode() { > if (rootNode =3D=3D null) { > loadTree(); > } > return rootNode; > } > public void setRootNode(TreeNode rootNode) { > this.rootNode =3D rootNode; > } > public TreeNode[] getRootNodes() { > if (rootNodes =3D=3D null) { > rootNodes =3D this.getRootNode().getChildren(); > } > return rootNodes; > } > public void setRootNodes(TreeNode[] rootNodes) { > this.rootNodes =3D rootNodes; > } > public TreeState getTreeState() { > return treeState; > } > public void setTreeState(TreeState treeState) { > this.treeState =3D treeState; > } > private void addNodes(String path, TreeNode node, Properties properties)= { > boolean end =3D false; > int counter =3D 1; > while (!end) { > String key =3D path !=3D null ? path + '.' + counter : String > .valueOf(counter); > String value =3D properties.getProperty(key); > if (value !=3D null) { > TreeNode newNode =3D new TreeNode(value); > newNode.setParent(node); > node.addNode(newNode); > addNodes(key, newNode, properties); > counter++; > } else { > end =3D true; > } > } > } > private void loadTree() { > System.out.println("TreeBean -> loadTree()"); > FacesContext facesContext =3D FacesContext.getCurrentInstance(); > ExternalContext externalContext =3D facesContext.getExternalContext(); > InputStream dataStream =3D externalContext.getResourceAsStream(DATA_PAT= H); > try { > Properties properties =3D new Properties(); > properties.load(dataStream); > rootNode =3D new TreeNode("root"); > addNodes(null, rootNode, properties); > // manual tree extension > TreeNode dummy =3D new TreeNode("Sichtlinie"); > int count =3D 0; > for (int i =3D 1; i <=3D 50; i++) { > count++; > TreeNode node =3D new TreeNode("i" + i); > for (int j =3D 1; j <=3D 200; j++) { > count++; > if (count % 1000 =3D=3D 0) { > System.out.println(count); > } > TreeNode child =3D new TreeNode("j" + j); > child.setParent(node); > node.addNode(child); > } > node.setParent(dummy); > dummy.addNode(node); > } > rootNode.addNode(dummy); > } catch (IOException e) { > e.printStackTrace(); > throw new FacesException(e.getMessage(), e); > } finally { > if (dataStream !=3D null) { > try { > dataStream.close(); > } catch (IOException e) { > e.printStackTrace(); > externalContext.log(e.getMessage(), e); > } > } > } > } > public void processSelection(NodeSelectedEvent arg0) > throws AbortProcessingException { > System.out.println("SimpleTreeBean -> processSelection fired by " > + arg0.getComponent().getId()); > }[/code] > TreeNode: > [code]package my_tree; > import javax.faces.event.ActionEvent; > import org.richfaces.model.TreeNodeImpl; > public class TreeNode{ > private String value; > private String state; > private TreeNode parent; > private TreeNode[] children; > = > public TreeNode(String value) { > this.value =3D value; > this.state =3D ""; > } > public synchronized void addNode(TreeNode newChild) { > System.out.println("addNode("+newChild.getValue()+")"); > if (this.children =3D=3D null) { > TreeNode[] merged =3D new TreeNode[1]; > merged[0] =3D newChild; > this.children =3D merged; > } else { > TreeNode[] merged =3D new TreeNode[this.children.length + 1]; > int i; > for (i =3D 0; i < this.children.length; i++) { > merged[i] =3D this.children[i]; > } > merged[merged.length - 1] =3D newChild; > this.children =3D merged; > } > } > public synchronized void addNodes(TreeNode[] newChildren) { > System.out.println("addNodeS("+newChildren.length+")"); > TreeNode[] merged =3D new TreeNode[newChildren.length > + this.children.length]; > int i; > for (i =3D 0; i <=3D this.children.length; i++) { > merged[i] =3D this.children[i]; > } > for (int i2 =3D i; i2 <=3D newChildren.length + i; i2++) { > merged[i2] =3D newChildren[i2]; > } > this.children =3D merged; > } > public synchronized void removeNodes(TreeNode[] removeChildren) { > TreeNode[] splitted =3D new TreeNode[this.children.length > - removeChildren.length]; > int pos =3D 0; > for (int i =3D 0; i <=3D this.children.length; i++) { > boolean contains =3D false; > for (int j =3D 0; j <=3D removeChildren.length; j++) { > if (this.children[i] =3D=3D removeChildren[j]) { > contains =3D true; > } > } > if (contains =3D=3D false) { > splitted[pos] =3D this.children[i]; > pos++; > } > } > } > public String checkSibling(){ > //System.out.println("checkSibling() of "+this.value); > if(this.children!=3Dnull){ > String state =3D null; > int checked =3D 0; > int sub =3D 0; > int i; = > TreeNode[] siblings =3D this.children; > for (i =3D 0; i < siblings.length; i++) { > = > TreeNode treeNode =3D siblings[i]; > //System.out.println("\t"+treeNode.getValue()+" - "+treeNode.getState= ()); > if(!treeNode.getState().equals("")){ > if(treeNode.getState().equals("checked")){ > checked++; > } else if(treeNode.getState().equals("sub")){ > sub++; > } > } > = > } > = > if(checked =3D=3D i){ > state =3D "checked"; > } else if(sub > 0 || checked > 0) { > state =3D "sub"; > } else { > state =3D ""; > } > //System.out.println("siblings: "+i+" (checked: "+checked+" sub: "+sub= +") -> "+state); > return state; > } else { > return ""; > } > } > = > public void setChildsChecked(TreeNode node){ > //System.out.println("TreeNode -> setChildsChecked of "+node.getValue()= ); > if(node.getChildren()!=3Dnull){ > TreeNode[] children =3D node.getChildren(); > for (int i =3D 0; i < children.length; i++) { > TreeNode treeNode =3D children[i]; > treeNode.setState("checked"); > setChildsChecked(treeNode); > } > } > } > = > public void setChildsUnchecked(TreeNode node){ > //System.out.println("TreeNode -> setChildsUnchecked of "+node.getValue= ()); > if(node.getChildren()!=3Dnull){ > TreeNode[] children =3D node.getChildren(); > for (int i =3D 0; i < children.length; i++) { > TreeNode treeNode =3D children[i]; > treeNode.setState(""); > setChildsUnchecked(treeNode); > } > } > } > public void setParentsState(TreeNode node){ > System.out.println("TreeNode -> setParentsState of "+node.getValue()); > node.setState(node.checkSibling()); > if(node.getParent()!=3Dnull){ > setParentsState(node.getParent()); > } > } = > = > public void actionListener(ActionEvent ae){ > //System.out.println("TreeNode -> nodeListener fired by "+ae.getCompone= nt().getId()); > if(this.state =3D=3D "checked"){ > this.state =3D ""; > setChildsUnchecked(this); > } else { > this.state =3D "checked"; > setChildsChecked(this); > } > if(this.parent!=3Dnull){ > setParentsState(this.parent); > } > = > } = > = > public String getValue() { > return value; > } > public void setValue(String value) { > this.value =3D value; > } > public TreeNode[] getChildren() { > return children; > } > public void setChildren(TreeNode[] children) { > this.children =3D children; > } > = > = > public TreeNode getParent() { > if(parent=3D=3Dnull){ > return null; > } else { > return parent; > } > } > public void setParent(TreeNode parent) { > this.parent =3D parent; > } > public String getState() { > return state; > } > public void setState(String state) { > this.state =3D state; > } > } > [/code] -- = This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: htt= p://jira.jboss.com/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira = --===============7886267154228774975==-- From jira-events at lists.jboss.org Wed Jun 4 05:09:20 2008 Content-Type: multipart/mixed; boundary="===============4273323919821574627==" MIME-Version: 1.0 From: Nick Belaevski (JIRA) To: richfaces-issues at lists.jboss.org Subject: [richfaces-issues] [JBoss JIRA] Commented: (RF-3569) possible performance issue Date: Wed, 04 Jun 2008 05:09:20 -0400 Message-ID: <17502336.1212570560652.JavaMail.jira@cloud.prod.atl2.jboss.com> In-Reply-To: 25135648.1211970229264.JavaMail.jira@cloud.prod.atl2.jboss.com --===============4273323919821574627== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable [ http://jira.jboss.com/jira/browse/RF-3569?page=3Dcomments#action_1241= 5511 ] = = Nick Belaevski commented on RF-3569: ------------------------------------ Martin, Nested tables have been removed from tree component since 3.1 version as fa= r as I remember. Could you please clarify? > possible performance issue = > --------------------------------------- > > Key: RF-3569 > URL: http://jira.jboss.com/jira/browse/RF-3569 > Project: RichFaces > Issue Type: Quality Risk > Affects Versions: 3.2.0 > Reporter: martin bischoff > Assigned To: Nick Belaevski > Fix For: 3.2.2 > > > i've got an quite simple tree with "just" 50 elements =C3=83?=C3=82=C2=A1= 200 childs -> 10.000 nodes > every node gots: > - some little text > - image for a checkbox via h:graphicImage > - a4j:support for listenersupport at the image > expanding/collapsing nodes and checking the checkboxes takes a lot of tim= e... > jprofiler tells me that most of the time is spend by domparsing. i dont k= now if i handle the tree as intended. here is some code: > JSP > [code] > <%@ taglib uri=3D"http://richfaces.org/a4j" prefix=3D"a4j"%> > <%@ taglib uri=3D"http://richfaces.org/rich" prefix=3D"rich"%> > <%@ taglib uri=3D"http://java.sun.com/jsf/html" prefix=3D"h"%> > <%@ taglib uri=3D"http://java.sun.com/jsf/core" prefix=3D"f"%> > > > tree > > > > > > > > > > > > > > = > > > > > > = > > > = > > > > > > > [/code] > TreeBean: > [code]package my_tree; > import java.io.IOException; > import java.io.InputStream; > import java.util.Properties; > import javax.faces.FacesException; > import javax.faces.context.ExternalContext; > import javax.faces.context.FacesContext; > import javax.faces.event.AbortProcessingException; > import org.richfaces.component.state.TreeState; > import org.richfaces.event.NodeSelectedEvent; > public class TreeBean { > private TreeNode rootNode =3D null; > private TreeNode[] rootNodes =3D null; > private TreeState treeState; > private static final String DATA_PATH =3D "/res/tree/simple-tree-data.pr= operties"; > public TreeNode getRootNode() { > if (rootNode =3D=3D null) { > loadTree(); > } > return rootNode; > } > public void setRootNode(TreeNode rootNode) { > this.rootNode =3D rootNode; > } > public TreeNode[] getRootNodes() { > if (rootNodes =3D=3D null) { > rootNodes =3D this.getRootNode().getChildren(); > } > return rootNodes; > } > public void setRootNodes(TreeNode[] rootNodes) { > this.rootNodes =3D rootNodes; > } > public TreeState getTreeState() { > return treeState; > } > public void setTreeState(TreeState treeState) { > this.treeState =3D treeState; > } > private void addNodes(String path, TreeNode node, Properties properties)= { > boolean end =3D false; > int counter =3D 1; > while (!end) { > String key =3D path !=3D null ? path + '.' + counter : String > .valueOf(counter); > String value =3D properties.getProperty(key); > if (value !=3D null) { > TreeNode newNode =3D new TreeNode(value); > newNode.setParent(node); > node.addNode(newNode); > addNodes(key, newNode, properties); > counter++; > } else { > end =3D true; > } > } > } > private void loadTree() { > System.out.println("TreeBean -> loadTree()"); > FacesContext facesContext =3D FacesContext.getCurrentInstance(); > ExternalContext externalContext =3D facesContext.getExternalContext(); > InputStream dataStream =3D externalContext.getResourceAsStream(DATA_PAT= H); > try { > Properties properties =3D new Properties(); > properties.load(dataStream); > rootNode =3D new TreeNode("root"); > addNodes(null, rootNode, properties); > // manual tree extension > TreeNode dummy =3D new TreeNode("Sichtlinie"); > int count =3D 0; > for (int i =3D 1; i <=3D 50; i++) { > count++; > TreeNode node =3D new TreeNode("i" + i); > for (int j =3D 1; j <=3D 200; j++) { > count++; > if (count % 1000 =3D=3D 0) { > System.out.println(count); > } > TreeNode child =3D new TreeNode("j" + j); > child.setParent(node); > node.addNode(child); > } > node.setParent(dummy); > dummy.addNode(node); > } > rootNode.addNode(dummy); > } catch (IOException e) { > e.printStackTrace(); > throw new FacesException(e.getMessage(), e); > } finally { > if (dataStream !=3D null) { > try { > dataStream.close(); > } catch (IOException e) { > e.printStackTrace(); > externalContext.log(e.getMessage(), e); > } > } > } > } > public void processSelection(NodeSelectedEvent arg0) > throws AbortProcessingException { > System.out.println("SimpleTreeBean -> processSelection fired by " > + arg0.getComponent().getId()); > }[/code] > TreeNode: > [code]package my_tree; > import javax.faces.event.ActionEvent; > import org.richfaces.model.TreeNodeImpl; > public class TreeNode{ > private String value; > private String state; > private TreeNode parent; > private TreeNode[] children; > = > public TreeNode(String value) { > this.value =3D value; > this.state =3D ""; > } > public synchronized void addNode(TreeNode newChild) { > System.out.println("addNode("+newChild.getValue()+")"); > if (this.children =3D=3D null) { > TreeNode[] merged =3D new TreeNode[1]; > merged[0] =3D newChild; > this.children =3D merged; > } else { > TreeNode[] merged =3D new TreeNode[this.children.length + 1]; > int i; > for (i =3D 0; i < this.children.length; i++) { > merged[i] =3D this.children[i]; > } > merged[merged.length - 1] =3D newChild; > this.children =3D merged; > } > } > public synchronized void addNodes(TreeNode[] newChildren) { > System.out.println("addNodeS("+newChildren.length+")"); > TreeNode[] merged =3D new TreeNode[newChildren.length > + this.children.length]; > int i; > for (i =3D 0; i <=3D this.children.length; i++) { > merged[i] =3D this.children[i]; > } > for (int i2 =3D i; i2 <=3D newChildren.length + i; i2++) { > merged[i2] =3D newChildren[i2]; > } > this.children =3D merged; > } > public synchronized void removeNodes(TreeNode[] removeChildren) { > TreeNode[] splitted =3D new TreeNode[this.children.length > - removeChildren.length]; > int pos =3D 0; > for (int i =3D 0; i <=3D this.children.length; i++) { > boolean contains =3D false; > for (int j =3D 0; j <=3D removeChildren.length; j++) { > if (this.children[i] =3D=3D removeChildren[j]) { > contains =3D true; > } > } > if (contains =3D=3D false) { > splitted[pos] =3D this.children[i]; > pos++; > } > } > } > public String checkSibling(){ > //System.out.println("checkSibling() of "+this.value); > if(this.children!=3Dnull){ > String state =3D null; > int checked =3D 0; > int sub =3D 0; > int i; = > TreeNode[] siblings =3D this.children; > for (i =3D 0; i < siblings.length; i++) { > = > TreeNode treeNode =3D siblings[i]; > //System.out.println("\t"+treeNode.getValue()+" - "+treeNode.getState= ()); > if(!treeNode.getState().equals("")){ > if(treeNode.getState().equals("checked")){ > checked++; > } else if(treeNode.getState().equals("sub")){ > sub++; > } > } > = > } > = > if(checked =3D=3D i){ > state =3D "checked"; > } else if(sub > 0 || checked > 0) { > state =3D "sub"; > } else { > state =3D ""; > } > //System.out.println("siblings: "+i+" (checked: "+checked+" sub: "+sub= +") -> "+state); > return state; > } else { > return ""; > } > } > = > public void setChildsChecked(TreeNode node){ > //System.out.println("TreeNode -> setChildsChecked of "+node.getValue()= ); > if(node.getChildren()!=3Dnull){ > TreeNode[] children =3D node.getChildren(); > for (int i =3D 0; i < children.length; i++) { > TreeNode treeNode =3D children[i]; > treeNode.setState("checked"); > setChildsChecked(treeNode); > } > } > } > = > public void setChildsUnchecked(TreeNode node){ > //System.out.println("TreeNode -> setChildsUnchecked of "+node.getValue= ()); > if(node.getChildren()!=3Dnull){ > TreeNode[] children =3D node.getChildren(); > for (int i =3D 0; i < children.length; i++) { > TreeNode treeNode =3D children[i]; > treeNode.setState(""); > setChildsUnchecked(treeNode); > } > } > } > public void setParentsState(TreeNode node){ > System.out.println("TreeNode -> setParentsState of "+node.getValue()); > node.setState(node.checkSibling()); > if(node.getParent()!=3Dnull){ > setParentsState(node.getParent()); > } > } = > = > public void actionListener(ActionEvent ae){ > //System.out.println("TreeNode -> nodeListener fired by "+ae.getCompone= nt().getId()); > if(this.state =3D=3D "checked"){ > this.state =3D ""; > setChildsUnchecked(this); > } else { > this.state =3D "checked"; > setChildsChecked(this); > } > if(this.parent!=3Dnull){ > setParentsState(this.parent); > } > = > } = > = > public String getValue() { > return value; > } > public void setValue(String value) { > this.value =3D value; > } > public TreeNode[] getChildren() { > return children; > } > public void setChildren(TreeNode[] children) { > this.children =3D children; > } > = > = > public TreeNode getParent() { > if(parent=3D=3Dnull){ > return null; > } else { > return parent; > } > } > public void setParent(TreeNode parent) { > this.parent =3D parent; > } > public String getState() { > return state; > } > public void setState(String state) { > this.state =3D state; > } > } > [/code] -- = This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: htt= p://jira.jboss.com/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira = --===============4273323919821574627==-- From jira-events at lists.jboss.org Wed Jun 4 08:38:31 2008 Content-Type: multipart/mixed; boundary="===============4216499792409051030==" MIME-Version: 1.0 From: martin bischoff (JIRA) To: richfaces-issues at lists.jboss.org Subject: [richfaces-issues] [JBoss JIRA] Commented: (RF-3569) possible performance issue Date: Wed, 04 Jun 2008 08:38:31 -0400 Message-ID: <28738793.1212583111026.JavaMail.jira@cloud.prod.atl2.jboss.com> In-Reply-To: 25135648.1211970229264.JavaMail.jira@cloud.prod.atl2.jboss.com --===============4216499792409051030== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable [ http://jira.jboss.com/jira/browse/RF-3569?page=3Dcomments#action_1241= 5550 ] = = martin bischoff commented on RF-3569: ------------------------------------- i articulated myself a little bit unfortunate. i mean the structure of the = single treenodes. in original its "nested" that way: div = |-table - tbody - tr - 3x td |-div |-table - tbody - tr - 3x td |-div ... i modified the structure to this nesting: ul |-li - div - 3x span |-li |-ul |- li - div - 3x span |- li ... > possible performance issue = > --------------------------------------- > > Key: RF-3569 > URL: http://jira.jboss.com/jira/browse/RF-3569 > Project: RichFaces > Issue Type: Quality Risk > Affects Versions: 3.2.0 > Reporter: martin bischoff > Assigned To: Nick Belaevski > Fix For: 3.2.2 > > > i've got an quite simple tree with "just" 50 elements =C3=83?=C3=82=C2=A1= 200 childs -> 10.000 nodes > every node gots: > - some little text > - image for a checkbox via h:graphicImage > - a4j:support for listenersupport at the image > expanding/collapsing nodes and checking the checkboxes takes a lot of tim= e... > jprofiler tells me that most of the time is spend by domparsing. i dont k= now if i handle the tree as intended. here is some code: > JSP > [code] > <%@ taglib uri=3D"http://richfaces.org/a4j" prefix=3D"a4j"%> > <%@ taglib uri=3D"http://richfaces.org/rich" prefix=3D"rich"%> > <%@ taglib uri=3D"http://java.sun.com/jsf/html" prefix=3D"h"%> > <%@ taglib uri=3D"http://java.sun.com/jsf/core" prefix=3D"f"%> > > > tree > > > > > > > > > > > > > > = > > > > > > = > > > = > > > > > > > [/code] > TreeBean: > [code]package my_tree; > import java.io.IOException; > import java.io.InputStream; > import java.util.Properties; > import javax.faces.FacesException; > import javax.faces.context.ExternalContext; > import javax.faces.context.FacesContext; > import javax.faces.event.AbortProcessingException; > import org.richfaces.component.state.TreeState; > import org.richfaces.event.NodeSelectedEvent; > public class TreeBean { > private TreeNode rootNode =3D null; > private TreeNode[] rootNodes =3D null; > private TreeState treeState; > private static final String DATA_PATH =3D "/res/tree/simple-tree-data.pr= operties"; > public TreeNode getRootNode() { > if (rootNode =3D=3D null) { > loadTree(); > } > return rootNode; > } > public void setRootNode(TreeNode rootNode) { > this.rootNode =3D rootNode; > } > public TreeNode[] getRootNodes() { > if (rootNodes =3D=3D null) { > rootNodes =3D this.getRootNode().getChildren(); > } > return rootNodes; > } > public void setRootNodes(TreeNode[] rootNodes) { > this.rootNodes =3D rootNodes; > } > public TreeState getTreeState() { > return treeState; > } > public void setTreeState(TreeState treeState) { > this.treeState =3D treeState; > } > private void addNodes(String path, TreeNode node, Properties properties)= { > boolean end =3D false; > int counter =3D 1; > while (!end) { > String key =3D path !=3D null ? path + '.' + counter : String > .valueOf(counter); > String value =3D properties.getProperty(key); > if (value !=3D null) { > TreeNode newNode =3D new TreeNode(value); > newNode.setParent(node); > node.addNode(newNode); > addNodes(key, newNode, properties); > counter++; > } else { > end =3D true; > } > } > } > private void loadTree() { > System.out.println("TreeBean -> loadTree()"); > FacesContext facesContext =3D FacesContext.getCurrentInstance(); > ExternalContext externalContext =3D facesContext.getExternalContext(); > InputStream dataStream =3D externalContext.getResourceAsStream(DATA_PAT= H); > try { > Properties properties =3D new Properties(); > properties.load(dataStream); > rootNode =3D new TreeNode("root"); > addNodes(null, rootNode, properties); > // manual tree extension > TreeNode dummy =3D new TreeNode("Sichtlinie"); > int count =3D 0; > for (int i =3D 1; i <=3D 50; i++) { > count++; > TreeNode node =3D new TreeNode("i" + i); > for (int j =3D 1; j <=3D 200; j++) { > count++; > if (count % 1000 =3D=3D 0) { > System.out.println(count); > } > TreeNode child =3D new TreeNode("j" + j); > child.setParent(node); > node.addNode(child); > } > node.setParent(dummy); > dummy.addNode(node); > } > rootNode.addNode(dummy); > } catch (IOException e) { > e.printStackTrace(); > throw new FacesException(e.getMessage(), e); > } finally { > if (dataStream !=3D null) { > try { > dataStream.close(); > } catch (IOException e) { > e.printStackTrace(); > externalContext.log(e.getMessage(), e); > } > } > } > } > public void processSelection(NodeSelectedEvent arg0) > throws AbortProcessingException { > System.out.println("SimpleTreeBean -> processSelection fired by " > + arg0.getComponent().getId()); > }[/code] > TreeNode: > [code]package my_tree; > import javax.faces.event.ActionEvent; > import org.richfaces.model.TreeNodeImpl; > public class TreeNode{ > private String value; > private String state; > private TreeNode parent; > private TreeNode[] children; > = > public TreeNode(String value) { > this.value =3D value; > this.state =3D ""; > } > public synchronized void addNode(TreeNode newChild) { > System.out.println("addNode("+newChild.getValue()+")"); > if (this.children =3D=3D null) { > TreeNode[] merged =3D new TreeNode[1]; > merged[0] =3D newChild; > this.children =3D merged; > } else { > TreeNode[] merged =3D new TreeNode[this.children.length + 1]; > int i; > for (i =3D 0; i < this.children.length; i++) { > merged[i] =3D this.children[i]; > } > merged[merged.length - 1] =3D newChild; > this.children =3D merged; > } > } > public synchronized void addNodes(TreeNode[] newChildren) { > System.out.println("addNodeS("+newChildren.length+")"); > TreeNode[] merged =3D new TreeNode[newChildren.length > + this.children.length]; > int i; > for (i =3D 0; i <=3D this.children.length; i++) { > merged[i] =3D this.children[i]; > } > for (int i2 =3D i; i2 <=3D newChildren.length + i; i2++) { > merged[i2] =3D newChildren[i2]; > } > this.children =3D merged; > } > public synchronized void removeNodes(TreeNode[] removeChildren) { > TreeNode[] splitted =3D new TreeNode[this.children.length > - removeChildren.length]; > int pos =3D 0; > for (int i =3D 0; i <=3D this.children.length; i++) { > boolean contains =3D false; > for (int j =3D 0; j <=3D removeChildren.length; j++) { > if (this.children[i] =3D=3D removeChildren[j]) { > contains =3D true; > } > } > if (contains =3D=3D false) { > splitted[pos] =3D this.children[i]; > pos++; > } > } > } > public String checkSibling(){ > //System.out.println("checkSibling() of "+this.value); > if(this.children!=3Dnull){ > String state =3D null; > int checked =3D 0; > int sub =3D 0; > int i; = > TreeNode[] siblings =3D this.children; > for (i =3D 0; i < siblings.length; i++) { > = > TreeNode treeNode =3D siblings[i]; > //System.out.println("\t"+treeNode.getValue()+" - "+treeNode.getState= ()); > if(!treeNode.getState().equals("")){ > if(treeNode.getState().equals("checked")){ > checked++; > } else if(treeNode.getState().equals("sub")){ > sub++; > } > } > = > } > = > if(checked =3D=3D i){ > state =3D "checked"; > } else if(sub > 0 || checked > 0) { > state =3D "sub"; > } else { > state =3D ""; > } > //System.out.println("siblings: "+i+" (checked: "+checked+" sub: "+sub= +") -> "+state); > return state; > } else { > return ""; > } > } > = > public void setChildsChecked(TreeNode node){ > //System.out.println("TreeNode -> setChildsChecked of "+node.getValue()= ); > if(node.getChildren()!=3Dnull){ > TreeNode[] children =3D node.getChildren(); > for (int i =3D 0; i < children.length; i++) { > TreeNode treeNode =3D children[i]; > treeNode.setState("checked"); > setChildsChecked(treeNode); > } > } > } > = > public void setChildsUnchecked(TreeNode node){ > //System.out.println("TreeNode -> setChildsUnchecked of "+node.getValue= ()); > if(node.getChildren()!=3Dnull){ > TreeNode[] children =3D node.getChildren(); > for (int i =3D 0; i < children.length; i++) { > TreeNode treeNode =3D children[i]; > treeNode.setState(""); > setChildsUnchecked(treeNode); > } > } > } > public void setParentsState(TreeNode node){ > System.out.println("TreeNode -> setParentsState of "+node.getValue()); > node.setState(node.checkSibling()); > if(node.getParent()!=3Dnull){ > setParentsState(node.getParent()); > } > } = > = > public void actionListener(ActionEvent ae){ > //System.out.println("TreeNode -> nodeListener fired by "+ae.getCompone= nt().getId()); > if(this.state =3D=3D "checked"){ > this.state =3D ""; > setChildsUnchecked(this); > } else { > this.state =3D "checked"; > setChildsChecked(this); > } > if(this.parent!=3Dnull){ > setParentsState(this.parent); > } > = > } = > = > public String getValue() { > return value; > } > public void setValue(String value) { > this.value =3D value; > } > public TreeNode[] getChildren() { > return children; > } > public void setChildren(TreeNode[] children) { > this.children =3D children; > } > = > = > public TreeNode getParent() { > if(parent=3D=3Dnull){ > return null; > } else { > return parent; > } > } > public void setParent(TreeNode parent) { > this.parent =3D parent; > } > public String getState() { > return state; > } > public void setState(String state) { > this.state =3D state; > } > } > [/code] -- = This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: htt= p://jira.jboss.com/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira = --===============4216499792409051030==-- From jira-events at lists.jboss.org Tue Jun 17 15:08:37 2008 Content-Type: multipart/mixed; boundary="===============7724769573517476164==" MIME-Version: 1.0 From: Nick Belaevski (JIRA) To: richfaces-issues at lists.jboss.org Subject: [richfaces-issues] [JBoss JIRA] Updated: (RF-3569) possible performance issue Date: Tue, 17 Jun 2008 15:08:37 -0400 Message-ID: <18177029.1213729717258.JavaMail.jira@cloud.prod.atl2.jboss.com> In-Reply-To: 25135648.1211970229264.JavaMail.jira@cloud.prod.atl2.jboss.com --===============7724769573517476164== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable [ http://jira.jboss.com/jira/browse/RF-3569?page=3Dall ] Nick Belaevski updated RF-3569: ------------------------------- Fix Version/s: 3.3.0 (was: 3.2.2) > possible performance issue = > --------------------------------------- > > Key: RF-3569 > URL: http://jira.jboss.com/jira/browse/RF-3569 > Project: RichFaces > Issue Type: Quality Risk > Affects Versions: 3.2.0 > Reporter: martin bischoff > Assigned To: Nick Belaevski > Fix For: 3.3.0 > > > i've got an quite simple tree with "just" 50 elements =C3=83?=C3=82=C2=A1= 200 childs -> 10.000 nodes > every node gots: > - some little text > - image for a checkbox via h:graphicImage > - a4j:support for listenersupport at the image > expanding/collapsing nodes and checking the checkboxes takes a lot of tim= e... > jprofiler tells me that most of the time is spend by domparsing. i dont k= now if i handle the tree as intended. here is some code: > JSP > [code] > <%@ taglib uri=3D"http://richfaces.org/a4j" prefix=3D"a4j"%> > <%@ taglib uri=3D"http://richfaces.org/rich" prefix=3D"rich"%> > <%@ taglib uri=3D"http://java.sun.com/jsf/html" prefix=3D"h"%> > <%@ taglib uri=3D"http://java.sun.com/jsf/core" prefix=3D"f"%> > > > tree > > > > > > > > > > > > > > = > > > > > > = > > > = > > > > > > > [/code] > TreeBean: > [code]package my_tree; > import java.io.IOException; > import java.io.InputStream; > import java.util.Properties; > import javax.faces.FacesException; > import javax.faces.context.ExternalContext; > import javax.faces.context.FacesContext; > import javax.faces.event.AbortProcessingException; > import org.richfaces.component.state.TreeState; > import org.richfaces.event.NodeSelectedEvent; > public class TreeBean { > private TreeNode rootNode =3D null; > private TreeNode[] rootNodes =3D null; > private TreeState treeState; > private static final String DATA_PATH =3D "/res/tree/simple-tree-data.pr= operties"; > public TreeNode getRootNode() { > if (rootNode =3D=3D null) { > loadTree(); > } > return rootNode; > } > public void setRootNode(TreeNode rootNode) { > this.rootNode =3D rootNode; > } > public TreeNode[] getRootNodes() { > if (rootNodes =3D=3D null) { > rootNodes =3D this.getRootNode().getChildren(); > } > return rootNodes; > } > public void setRootNodes(TreeNode[] rootNodes) { > this.rootNodes =3D rootNodes; > } > public TreeState getTreeState() { > return treeState; > } > public void setTreeState(TreeState treeState) { > this.treeState =3D treeState; > } > private void addNodes(String path, TreeNode node, Properties properties)= { > boolean end =3D false; > int counter =3D 1; > while (!end) { > String key =3D path !=3D null ? path + '.' + counter : String > .valueOf(counter); > String value =3D properties.getProperty(key); > if (value !=3D null) { > TreeNode newNode =3D new TreeNode(value); > newNode.setParent(node); > node.addNode(newNode); > addNodes(key, newNode, properties); > counter++; > } else { > end =3D true; > } > } > } > private void loadTree() { > System.out.println("TreeBean -> loadTree()"); > FacesContext facesContext =3D FacesContext.getCurrentInstance(); > ExternalContext externalContext =3D facesContext.getExternalContext(); > InputStream dataStream =3D externalContext.getResourceAsStream(DATA_PAT= H); > try { > Properties properties =3D new Properties(); > properties.load(dataStream); > rootNode =3D new TreeNode("root"); > addNodes(null, rootNode, properties); > // manual tree extension > TreeNode dummy =3D new TreeNode("Sichtlinie"); > int count =3D 0; > for (int i =3D 1; i <=3D 50; i++) { > count++; > TreeNode node =3D new TreeNode("i" + i); > for (int j =3D 1; j <=3D 200; j++) { > count++; > if (count % 1000 =3D=3D 0) { > System.out.println(count); > } > TreeNode child =3D new TreeNode("j" + j); > child.setParent(node); > node.addNode(child); > } > node.setParent(dummy); > dummy.addNode(node); > } > rootNode.addNode(dummy); > } catch (IOException e) { > e.printStackTrace(); > throw new FacesException(e.getMessage(), e); > } finally { > if (dataStream !=3D null) { > try { > dataStream.close(); > } catch (IOException e) { > e.printStackTrace(); > externalContext.log(e.getMessage(), e); > } > } > } > } > public void processSelection(NodeSelectedEvent arg0) > throws AbortProcessingException { > System.out.println("SimpleTreeBean -> processSelection fired by " > + arg0.getComponent().getId()); > }[/code] > TreeNode: > [code]package my_tree; > import javax.faces.event.ActionEvent; > import org.richfaces.model.TreeNodeImpl; > public class TreeNode{ > private String value; > private String state; > private TreeNode parent; > private TreeNode[] children; > = > public TreeNode(String value) { > this.value =3D value; > this.state =3D ""; > } > public synchronized void addNode(TreeNode newChild) { > System.out.println("addNode("+newChild.getValue()+")"); > if (this.children =3D=3D null) { > TreeNode[] merged =3D new TreeNode[1]; > merged[0] =3D newChild; > this.children =3D merged; > } else { > TreeNode[] merged =3D new TreeNode[this.children.length + 1]; > int i; > for (i =3D 0; i < this.children.length; i++) { > merged[i] =3D this.children[i]; > } > merged[merged.length - 1] =3D newChild; > this.children =3D merged; > } > } > public synchronized void addNodes(TreeNode[] newChildren) { > System.out.println("addNodeS("+newChildren.length+")"); > TreeNode[] merged =3D new TreeNode[newChildren.length > + this.children.length]; > int i; > for (i =3D 0; i <=3D this.children.length; i++) { > merged[i] =3D this.children[i]; > } > for (int i2 =3D i; i2 <=3D newChildren.length + i; i2++) { > merged[i2] =3D newChildren[i2]; > } > this.children =3D merged; > } > public synchronized void removeNodes(TreeNode[] removeChildren) { > TreeNode[] splitted =3D new TreeNode[this.children.length > - removeChildren.length]; > int pos =3D 0; > for (int i =3D 0; i <=3D this.children.length; i++) { > boolean contains =3D false; > for (int j =3D 0; j <=3D removeChildren.length; j++) { > if (this.children[i] =3D=3D removeChildren[j]) { > contains =3D true; > } > } > if (contains =3D=3D false) { > splitted[pos] =3D this.children[i]; > pos++; > } > } > } > public String checkSibling(){ > //System.out.println("checkSibling() of "+this.value); > if(this.children!=3Dnull){ > String state =3D null; > int checked =3D 0; > int sub =3D 0; > int i; = > TreeNode[] siblings =3D this.children; > for (i =3D 0; i < siblings.length; i++) { > = > TreeNode treeNode =3D siblings[i]; > //System.out.println("\t"+treeNode.getValue()+" - "+treeNode.getState= ()); > if(!treeNode.getState().equals("")){ > if(treeNode.getState().equals("checked")){ > checked++; > } else if(treeNode.getState().equals("sub")){ > sub++; > } > } > = > } > = > if(checked =3D=3D i){ > state =3D "checked"; > } else if(sub > 0 || checked > 0) { > state =3D "sub"; > } else { > state =3D ""; > } > //System.out.println("siblings: "+i+" (checked: "+checked+" sub: "+sub= +") -> "+state); > return state; > } else { > return ""; > } > } > = > public void setChildsChecked(TreeNode node){ > //System.out.println("TreeNode -> setChildsChecked of "+node.getValue()= ); > if(node.getChildren()!=3Dnull){ > TreeNode[] children =3D node.getChildren(); > for (int i =3D 0; i < children.length; i++) { > TreeNode treeNode =3D children[i]; > treeNode.setState("checked"); > setChildsChecked(treeNode); > } > } > } > = > public void setChildsUnchecked(TreeNode node){ > //System.out.println("TreeNode -> setChildsUnchecked of "+node.getValue= ()); > if(node.getChildren()!=3Dnull){ > TreeNode[] children =3D node.getChildren(); > for (int i =3D 0; i < children.length; i++) { > TreeNode treeNode =3D children[i]; > treeNode.setState(""); > setChildsUnchecked(treeNode); > } > } > } > public void setParentsState(TreeNode node){ > System.out.println("TreeNode -> setParentsState of "+node.getValue()); > node.setState(node.checkSibling()); > if(node.getParent()!=3Dnull){ > setParentsState(node.getParent()); > } > } = > = > public void actionListener(ActionEvent ae){ > //System.out.println("TreeNode -> nodeListener fired by "+ae.getCompone= nt().getId()); > if(this.state =3D=3D "checked"){ > this.state =3D ""; > setChildsUnchecked(this); > } else { > this.state =3D "checked"; > setChildsChecked(this); > } > if(this.parent!=3Dnull){ > setParentsState(this.parent); > } > = > } = > = > public String getValue() { > return value; > } > public void setValue(String value) { > this.value =3D value; > } > public TreeNode[] getChildren() { > return children; > } > public void setChildren(TreeNode[] children) { > this.children =3D children; > } > = > = > public TreeNode getParent() { > if(parent=3D=3Dnull){ > return null; > } else { > return parent; > } > } > public void setParent(TreeNode parent) { > this.parent =3D parent; > } > public String getState() { > return state; > } > public void setState(String state) { > this.state =3D state; > } > } > [/code] -- = This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: htt= p://jira.jboss.com/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira = --===============7724769573517476164==-- From jira-events at lists.jboss.org Mon Jun 23 02:53:37 2008 Content-Type: multipart/mixed; boundary="===============8271004315838515769==" MIME-Version: 1.0 From: martin bischoff (JIRA) To: richfaces-issues at lists.jboss.org Subject: [richfaces-issues] [JBoss JIRA] Commented: (RF-3569) possible performance issue Date: Mon, 23 Jun 2008 02:53:37 -0400 Message-ID: <16166521.1214204017636.JavaMail.jira@cloud.prod.atl2.jboss.com> In-Reply-To: 25135648.1211970229264.JavaMail.jira@cloud.prod.atl2.jboss.com --===============8271004315838515769== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable [ http://jira.jboss.com/jira/browse/RF-3569?page=3Dcomments#action_1241= 8395 ] = = martin bischoff commented on RF-3569: ------------------------------------- my personal workaround for my problem: my demand was when i click on a random node in the tree, a refresh of all c= hilds and parents occur. i hacked the TreeRendererBase.java to achieve my g= oal and it works greats. heres the snippet, maybe it helps you: inject at line 465 @ TreeRendererBase.java String[] split =3D treeClientId.split(NamingContainer.SEPARATOR_CHAR+""); for (int i =3D 0; i < split.length; i++) { String string =3D split[i]; System.out.println(string); } int parents =3D (split.length-6)/2; String begin =3D split[0]+NamingContainer.SEPARATOR_CHAR+split[1]; String end =3D split[split.length-2]+ NamingContainer.SEPARATOR_CHAR+split= [split.length-1]; System.out.println("parents to render: "+parents); for(int i =3D 1; i<=3D parents; i++){ String center =3D ""; for(int j =3D 1; j<=3Di; j++){ center +=3D NamingContainer.SEPARATOR_CHAR+split[j*2]+NamingContainer.SE= PARATOR_CHAR+split[j*2+1]; } = final String parent =3D begin+center+NamingContainer.SEPARATOR_CHAR+end; System.out.println("parent: "+parent); System.out.println("parentUI ? : "+tree.invokeOnComponent(context, parent= , new ContextCallback(){ public void invokeContextCallback( FacesContext arg0, UIComponent arg1) { System.out.println("parentUI: "+arg1.getId()); System.out.println("parentClientID: "+arg1.getClientId(arg0)); ids.add(parent); renderedAreas.add(parent); // rerender parentcomponent try { List childList =3D arg1.getChildren(); arg1.encodeBegin(arg0); arg1.encodeChildren(arg0); for(Iterator iter =3D childList.iterator();iter.hasNext();){ UIComponent child =3D (UIComponent)iter.next(); System.out .println("parent child: "+child.getId()); System.out .println("parent child: "+child.getClientId(arg0)); // childs will not be rendered -> contextcallback on // every child arg1.invokeOnComponent(arg0, child.getClientId(arg0), new ContextCal= lback(){ public void invokeContextCallback(FacesContext arg0,UIComponent arg= 1){ try { arg1.encodeBegin(arg0); arg1.encodeEnd(arg0); } catch (Exception e) { // TODO: handle exception } } }); // works! } = = arg1.encodeEnd(arg0); = } catch (Exception e) { // TODO: handle exception } } = })); } = > possible performance issue = > --------------------------------------- > > Key: RF-3569 > URL: http://jira.jboss.com/jira/browse/RF-3569 > Project: RichFaces > Issue Type: Quality Risk > Affects Versions: 3.2.0 > Reporter: martin bischoff > Assigned To: Nick Belaevski > Fix For: 3.3.0 > > > i've got an quite simple tree with "just" 50 elements =C3=83?=C3=82=C2=A1= 200 childs -> 10.000 nodes > every node gots: > - some little text > - image for a checkbox via h:graphicImage > - a4j:support for listenersupport at the image > expanding/collapsing nodes and checking the checkboxes takes a lot of tim= e... > jprofiler tells me that most of the time is spend by domparsing. i dont k= now if i handle the tree as intended. here is some code: > JSP > [code] > <%@ taglib uri=3D"http://richfaces.org/a4j" prefix=3D"a4j"%> > <%@ taglib uri=3D"http://richfaces.org/rich" prefix=3D"rich"%> > <%@ taglib uri=3D"http://java.sun.com/jsf/html" prefix=3D"h"%> > <%@ taglib uri=3D"http://java.sun.com/jsf/core" prefix=3D"f"%> > > > tree > > > > > > > > > > > > > > = > > > > > > = > > > = > > > > > > > [/code] > TreeBean: > [code]package my_tree; > import java.io.IOException; > import java.io.InputStream; > import java.util.Properties; > import javax.faces.FacesException; > import javax.faces.context.ExternalContext; > import javax.faces.context.FacesContext; > import javax.faces.event.AbortProcessingException; > import org.richfaces.component.state.TreeState; > import org.richfaces.event.NodeSelectedEvent; > public class TreeBean { > private TreeNode rootNode =3D null; > private TreeNode[] rootNodes =3D null; > private TreeState treeState; > private static final String DATA_PATH =3D "/res/tree/simple-tree-data.pr= operties"; > public TreeNode getRootNode() { > if (rootNode =3D=3D null) { > loadTree(); > } > return rootNode; > } > public void setRootNode(TreeNode rootNode) { > this.rootNode =3D rootNode; > } > public TreeNode[] getRootNodes() { > if (rootNodes =3D=3D null) { > rootNodes =3D this.getRootNode().getChildren(); > } > return rootNodes; > } > public void setRootNodes(TreeNode[] rootNodes) { > this.rootNodes =3D rootNodes; > } > public TreeState getTreeState() { > return treeState; > } > public void setTreeState(TreeState treeState) { > this.treeState =3D treeState; > } > private void addNodes(String path, TreeNode node, Properties properties)= { > boolean end =3D false; > int counter =3D 1; > while (!end) { > String key =3D path !=3D null ? path + '.' + counter : String > .valueOf(counter); > String value =3D properties.getProperty(key); > if (value !=3D null) { > TreeNode newNode =3D new TreeNode(value); > newNode.setParent(node); > node.addNode(newNode); > addNodes(key, newNode, properties); > counter++; > } else { > end =3D true; > } > } > } > private void loadTree() { > System.out.println("TreeBean -> loadTree()"); > FacesContext facesContext =3D FacesContext.getCurrentInstance(); > ExternalContext externalContext =3D facesContext.getExternalContext(); > InputStream dataStream =3D externalContext.getResourceAsStream(DATA_PAT= H); > try { > Properties properties =3D new Properties(); > properties.load(dataStream); > rootNode =3D new TreeNode("root"); > addNodes(null, rootNode, properties); > // manual tree extension > TreeNode dummy =3D new TreeNode("Sichtlinie"); > int count =3D 0; > for (int i =3D 1; i <=3D 50; i++) { > count++; > TreeNode node =3D new TreeNode("i" + i); > for (int j =3D 1; j <=3D 200; j++) { > count++; > if (count % 1000 =3D=3D 0) { > System.out.println(count); > } > TreeNode child =3D new TreeNode("j" + j); > child.setParent(node); > node.addNode(child); > } > node.setParent(dummy); > dummy.addNode(node); > } > rootNode.addNode(dummy); > } catch (IOException e) { > e.printStackTrace(); > throw new FacesException(e.getMessage(), e); > } finally { > if (dataStream !=3D null) { > try { > dataStream.close(); > } catch (IOException e) { > e.printStackTrace(); > externalContext.log(e.getMessage(), e); > } > } > } > } > public void processSelection(NodeSelectedEvent arg0) > throws AbortProcessingException { > System.out.println("SimpleTreeBean -> processSelection fired by " > + arg0.getComponent().getId()); > }[/code] > TreeNode: > [code]package my_tree; > import javax.faces.event.ActionEvent; > import org.richfaces.model.TreeNodeImpl; > public class TreeNode{ > private String value; > private String state; > private TreeNode parent; > private TreeNode[] children; > = > public TreeNode(String value) { > this.value =3D value; > this.state =3D ""; > } > public synchronized void addNode(TreeNode newChild) { > System.out.println("addNode("+newChild.getValue()+")"); > if (this.children =3D=3D null) { > TreeNode[] merged =3D new TreeNode[1]; > merged[0] =3D newChild; > this.children =3D merged; > } else { > TreeNode[] merged =3D new TreeNode[this.children.length + 1]; > int i; > for (i =3D 0; i < this.children.length; i++) { > merged[i] =3D this.children[i]; > } > merged[merged.length - 1] =3D newChild; > this.children =3D merged; > } > } > public synchronized void addNodes(TreeNode[] newChildren) { > System.out.println("addNodeS("+newChildren.length+")"); > TreeNode[] merged =3D new TreeNode[newChildren.length > + this.children.length]; > int i; > for (i =3D 0; i <=3D this.children.length; i++) { > merged[i] =3D this.children[i]; > } > for (int i2 =3D i; i2 <=3D newChildren.length + i; i2++) { > merged[i2] =3D newChildren[i2]; > } > this.children =3D merged; > } > public synchronized void removeNodes(TreeNode[] removeChildren) { > TreeNode[] splitted =3D new TreeNode[this.children.length > - removeChildren.length]; > int pos =3D 0; > for (int i =3D 0; i <=3D this.children.length; i++) { > boolean contains =3D false; > for (int j =3D 0; j <=3D removeChildren.length; j++) { > if (this.children[i] =3D=3D removeChildren[j]) { > contains =3D true; > } > } > if (contains =3D=3D false) { > splitted[pos] =3D this.children[i]; > pos++; > } > } > } > public String checkSibling(){ > //System.out.println("checkSibling() of "+this.value); > if(this.children!=3Dnull){ > String state =3D null; > int checked =3D 0; > int sub =3D 0; > int i; = > TreeNode[] siblings =3D this.children; > for (i =3D 0; i < siblings.length; i++) { > = > TreeNode treeNode =3D siblings[i]; > //System.out.println("\t"+treeNode.getValue()+" - "+treeNode.getState= ()); > if(!treeNode.getState().equals("")){ > if(treeNode.getState().equals("checked")){ > checked++; > } else if(treeNode.getState().equals("sub")){ > sub++; > } > } > = > } > = > if(checked =3D=3D i){ > state =3D "checked"; > } else if(sub > 0 || checked > 0) { > state =3D "sub"; > } else { > state =3D ""; > } > //System.out.println("siblings: "+i+" (checked: "+checked+" sub: "+sub= +") -> "+state); > return state; > } else { > return ""; > } > } > = > public void setChildsChecked(TreeNode node){ > //System.out.println("TreeNode -> setChildsChecked of "+node.getValue()= ); > if(node.getChildren()!=3Dnull){ > TreeNode[] children =3D node.getChildren(); > for (int i =3D 0; i < children.length; i++) { > TreeNode treeNode =3D children[i]; > treeNode.setState("checked"); > setChildsChecked(treeNode); > } > } > } > = > public void setChildsUnchecked(TreeNode node){ > //System.out.println("TreeNode -> setChildsUnchecked of "+node.getValue= ()); > if(node.getChildren()!=3Dnull){ > TreeNode[] children =3D node.getChildren(); > for (int i =3D 0; i < children.length; i++) { > TreeNode treeNode =3D children[i]; > treeNode.setState(""); > setChildsUnchecked(treeNode); > } > } > } > public void setParentsState(TreeNode node){ > System.out.println("TreeNode -> setParentsState of "+node.getValue()); > node.setState(node.checkSibling()); > if(node.getParent()!=3Dnull){ > setParentsState(node.getParent()); > } > } = > = > public void actionListener(ActionEvent ae){ > //System.out.println("TreeNode -> nodeListener fired by "+ae.getCompone= nt().getId()); > if(this.state =3D=3D "checked"){ > this.state =3D ""; > setChildsUnchecked(this); > } else { > this.state =3D "checked"; > setChildsChecked(this); > } > if(this.parent!=3Dnull){ > setParentsState(this.parent); > } > = > } = > = > public String getValue() { > return value; > } > public void setValue(String value) { > this.value =3D value; > } > public TreeNode[] getChildren() { > return children; > } > public void setChildren(TreeNode[] children) { > this.children =3D children; > } > = > = > public TreeNode getParent() { > if(parent=3D=3Dnull){ > return null; > } else { > return parent; > } > } > public void setParent(TreeNode parent) { > this.parent =3D parent; > } > public String getState() { > return state; > } > public void setState(String state) { > this.state =3D state; > } > } > [/code] -- = This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: htt= p://jira.jboss.com/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira = --===============8271004315838515769==-- From jira-events at lists.jboss.org Sat Dec 20 12:21:54 2008 Content-Type: multipart/mixed; boundary="===============0011650733177867278==" MIME-Version: 1.0 From: Nick Belaevski (JIRA) To: richfaces-issues at lists.jboss.org Subject: [richfaces-issues] [JBoss JIRA] Updated: (RF-3569) possible performance issue Date: Sat, 20 Dec 2008 12:21:54 -0500 Message-ID: <11285317.1229793714682.JavaMail.jira@cloud.prod.atl2.jboss.com> In-Reply-To: 25135648.1211970229264.JavaMail.jira@cloud.prod.atl2.jboss.com --===============0011650733177867278== Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable [ https://jira.jboss.org/jira/browse/RF-3569?page=3Dcom.atlassian.jira= .plugin.system.issuetabpanels:all-tabpanel ] Nick Belaevski updated RF-3569: ------------------------------- Fix Version/s: Future (was: 3.3.0) > possible performance issue = > --------------------------------------- > > Key: RF-3569 > URL: https://jira.jboss.org/jira/browse/RF-3569 > Project: RichFaces > Issue Type: Quality Risk > Affects Versions: 3.2.0 > Reporter: martin bischoff > Assignee: Nick Belaevski > Fix For: Future > > > i've got an quite simple tree with "just" 50 elements =C3=83?=C3=82=C2=A1= 200 childs -> 10.000 nodes > every node gots: > - some little text > - image for a checkbox via h:graphicImage > - a4j:support for listenersupport at the image > expanding/collapsing nodes and checking the checkboxes takes a lot of tim= e... > jprofiler tells me that most of the time is spend by domparsing. i dont k= now if i handle the tree as intended. here is some code: > JSP > [code] > <%@ taglib uri=3D"http://richfaces.org/a4j" prefix=3D"a4j"%> > <%@ taglib uri=3D"http://richfaces.org/rich" prefix=3D"rich"%> > <%@ taglib uri=3D"http://java.sun.com/jsf/html" prefix=3D"h"%> > <%@ taglib uri=3D"http://java.sun.com/jsf/core" prefix=3D"f"%> > > > tree > > > > > > > > > > > > > > = > > > > > > = > > > = > > > > > > > [/code] > TreeBean: > [code]package my_tree; > import java.io.IOException; > import java.io.InputStream; > import java.util.Properties; > import javax.faces.FacesException; > import javax.faces.context.ExternalContext; > import javax.faces.context.FacesContext; > import javax.faces.event.AbortProcessingException; > import org.richfaces.component.state.TreeState; > import org.richfaces.event.NodeSelectedEvent; > public class TreeBean { > private TreeNode rootNode =3D null; > private TreeNode[] rootNodes =3D null; > private TreeState treeState; > private static final String DATA_PATH =3D "/res/tree/simple-tree-data.pr= operties"; > public TreeNode getRootNode() { > if (rootNode =3D=3D null) { > loadTree(); > } > return rootNode; > } > public void setRootNode(TreeNode rootNode) { > this.rootNode =3D rootNode; > } > public TreeNode[] getRootNodes() { > if (rootNodes =3D=3D null) { > rootNodes =3D this.getRootNode().getChildren(); > } > return rootNodes; > } > public void setRootNodes(TreeNode[] rootNodes) { > this.rootNodes =3D rootNodes; > } > public TreeState getTreeState() { > return treeState; > } > public void setTreeState(TreeState treeState) { > this.treeState =3D treeState; > } > private void addNodes(String path, TreeNode node, Properties properties)= { > boolean end =3D false; > int counter =3D 1; > while (!end) { > String key =3D path !=3D null ? path + '.' + counter : String > .valueOf(counter); > String value =3D properties.getProperty(key); > if (value !=3D null) { > TreeNode newNode =3D new TreeNode(value); > newNode.setParent(node); > node.addNode(newNode); > addNodes(key, newNode, properties); > counter++; > } else { > end =3D true; > } > } > } > private void loadTree() { > System.out.println("TreeBean -> loadTree()"); > FacesContext facesContext =3D FacesContext.getCurrentInstance(); > ExternalContext externalContext =3D facesContext.getExternalContext(); > InputStream dataStream =3D externalContext.getResourceAsStream(DATA_PAT= H); > try { > Properties properties =3D new Properties(); > properties.load(dataStream); > rootNode =3D new TreeNode("root"); > addNodes(null, rootNode, properties); > // manual tree extension > TreeNode dummy =3D new TreeNode("Sichtlinie"); > int count =3D 0; > for (int i =3D 1; i <=3D 50; i++) { > count++; > TreeNode node =3D new TreeNode("i" + i); > for (int j =3D 1; j <=3D 200; j++) { > count++; > if (count % 1000 =3D=3D 0) { > System.out.println(count); > } > TreeNode child =3D new TreeNode("j" + j); > child.setParent(node); > node.addNode(child); > } > node.setParent(dummy); > dummy.addNode(node); > } > rootNode.addNode(dummy); > } catch (IOException e) { > e.printStackTrace(); > throw new FacesException(e.getMessage(), e); > } finally { > if (dataStream !=3D null) { > try { > dataStream.close(); > } catch (IOException e) { > e.printStackTrace(); > externalContext.log(e.getMessage(), e); > } > } > } > } > public void processSelection(NodeSelectedEvent arg0) > throws AbortProcessingException { > System.out.println("SimpleTreeBean -> processSelection fired by " > + arg0.getComponent().getId()); > }[/code] > TreeNode: > [code]package my_tree; > import javax.faces.event.ActionEvent; > import org.richfaces.model.TreeNodeImpl; > public class TreeNode{ > private String value; > private String state; > private TreeNode parent; > private TreeNode[] children; > = > public TreeNode(String value) { > this.value =3D value; > this.state =3D ""; > } > public synchronized void addNode(TreeNode newChild) { > System.out.println("addNode("+newChild.getValue()+")"); > if (this.children =3D=3D null) { > TreeNode[] merged =3D new TreeNode[1]; > merged[0] =3D newChild; > this.children =3D merged; > } else { > TreeNode[] merged =3D new TreeNode[this.children.length + 1]; > int i; > for (i =3D 0; i < this.children.length; i++) { > merged[i] =3D this.children[i]; > } > merged[merged.length - 1] =3D newChild; > this.children =3D merged; > } > } > public synchronized void addNodes(TreeNode[] newChildren) { > System.out.println("addNodeS("+newChildren.length+")"); > TreeNode[] merged =3D new TreeNode[newChildren.length > + this.children.length]; > int i; > for (i =3D 0; i <=3D this.children.length; i++) { > merged[i] =3D this.children[i]; > } > for (int i2 =3D i; i2 <=3D newChildren.length + i; i2++) { > merged[i2] =3D newChildren[i2]; > } > this.children =3D merged; > } > public synchronized void removeNodes(TreeNode[] removeChildren) { > TreeNode[] splitted =3D new TreeNode[this.children.length > - removeChildren.length]; > int pos =3D 0; > for (int i =3D 0; i <=3D this.children.length; i++) { > boolean contains =3D false; > for (int j =3D 0; j <=3D removeChildren.length; j++) { > if (this.children[i] =3D=3D removeChildren[j]) { > contains =3D true; > } > } > if (contains =3D=3D false) { > splitted[pos] =3D this.children[i]; > pos++; > } > } > } > public String checkSibling(){ > //System.out.println("checkSibling() of "+this.value); > if(this.children!=3Dnull){ > String state =3D null; > int checked =3D 0; > int sub =3D 0; > int i; = > TreeNode[] siblings =3D this.children; > for (i =3D 0; i < siblings.length; i++) { > = > TreeNode treeNode =3D siblings[i]; > //System.out.println("\t"+treeNode.getValue()+" - "+treeNode.getState= ()); > if(!treeNode.getState().equals("")){ > if(treeNode.getState().equals("checked")){ > checked++; > } else if(treeNode.getState().equals("sub")){ > sub++; > } > } > = > } > = > if(checked =3D=3D i){ > state =3D "checked"; > } else if(sub > 0 || checked > 0) { > state =3D "sub"; > } else { > state =3D ""; > } > //System.out.println("siblings: "+i+" (checked: "+checked+" sub: "+sub= +") -> "+state); > return state; > } else { > return ""; > } > } > = > public void setChildsChecked(TreeNode node){ > //System.out.println("TreeNode -> setChildsChecked of "+node.getValue()= ); > if(node.getChildren()!=3Dnull){ > TreeNode[] children =3D node.getChildren(); > for (int i =3D 0; i < children.length; i++) { > TreeNode treeNode =3D children[i]; > treeNode.setState("checked"); > setChildsChecked(treeNode); > } > } > } > = > public void setChildsUnchecked(TreeNode node){ > //System.out.println("TreeNode -> setChildsUnchecked of "+node.getValue= ()); > if(node.getChildren()!=3Dnull){ > TreeNode[] children =3D node.getChildren(); > for (int i =3D 0; i < children.length; i++) { > TreeNode treeNode =3D children[i]; > treeNode.setState(""); > setChildsUnchecked(treeNode); > } > } > } > public void setParentsState(TreeNode node){ > System.out.println("TreeNode -> setParentsState of "+node.getValue()); > node.setState(node.checkSibling()); > if(node.getParent()!=3Dnull){ > setParentsState(node.getParent()); > } > } = > = > public void actionListener(ActionEvent ae){ > //System.out.println("TreeNode -> nodeListener fired by "+ae.getCompone= nt().getId()); > if(this.state =3D=3D "checked"){ > this.state =3D ""; > setChildsUnchecked(this); > } else { > this.state =3D "checked"; > setChildsChecked(this); > } > if(this.parent!=3Dnull){ > setParentsState(this.parent); > } > = > } = > = > public String getValue() { > return value; > } > public void setValue(String value) { > this.value =3D value; > } > public TreeNode[] getChildren() { > return children; > } > public void setChildren(TreeNode[] children) { > this.children =3D children; > } > = > = > public TreeNode getParent() { > if(parent=3D=3Dnull){ > return null; > } else { > return parent; > } > } > public void setParent(TreeNode parent) { > this.parent =3D parent; > } > public String getState() { > return state; > } > public void setState(String state) { > this.state =3D state; > } > } > [/code] -- = This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: htt= ps://jira.jboss.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira = --===============0011650733177867278==--