PrimeFaces Treetable Duplicate Row

UI Components for JSF
Post Reply
tonyelaltaico
Posts: 33
Joined: 20 Sep 2012, 16:07

15 Oct 2014, 16:31

Hello

I have a major problem with treeTable of primefaces.

When I click once in treetable i can see rows without any problem as listed in database.

But when I click subrow more than once then I see subrows duplicated. When I refresh the page, duplicate rows disappeared. I think the problem comes with the view as the duplicated rows do not reside in DB. I would be glad if you can help me. You can see the code for treeTable and nodeExpand below.

Regards
Alper Kopuz

tree.xhtml

Code: Select all


<p:treeTable value="#{treeBean.root}" var="suBomDetTreeNode" id="treeTable">
				<p:ajax event="expand" listener="#{treeBean.onNodeExpand}"/>
				<f:facet name="header">
             #{msg['Page.BomTree.urunAgaci']}
        </f:facet>
        		<p:column headerText="#{msg['sku']}">
					<h:outputText value="#{suBomDetTreeNode.skuName}" />
				</p:column>
				<p:column headerText="#{msg['Page.tree.detType']}">
					<h:outputText value="#{suBomDetTreeNode.skuType}" />
				</p:column>
				<p:column headerText="#{msg['Page.BomDet.detDesc']}" style="text-align: center;">
					<h:outputText value="#{suBomDetTreeNode.skuDescription}" />
				</p:column>
				<p:column headerText="#{msg['BomDet.validFrom']}" style="text-align: center;">
					<h:outputText value="#{suBomDetTreeNode.validFrom}">
						<f:convertDateTime pattern="YYYY/MM/dd"/>
					</h:outputText>
				</p:column>
				<p:column headerText="#{msg['BomDet.validTo']}" style="text-align: center;"> 
					<h:outputText value="#{suBomDetTreeNode.validTo}">
						<f:convertDateTime pattern="YYYY/MM/dd"/>
					</h:outputText>
				</p:column>
				<p:column headerText="#{msg['Page.quantity']}" style="text-align: center;">
					<h:outputText value="#{suBomDetTreeNode.qtyUmCode}" />
				</p:column>
				<p:column  style="text-align: center; width:30px;">
					<p:commandButton icon="ui-icon-arrowthick-1-s"  update=":treeForm:treeTable :dialogTestForm:recordDialogId" oncomplete="newLeafDialog.show();" 
					action="#{treeBean.generateSuBomDetFromTree(suBomDetTreeNode)}" title="#{msg['addNewRecord']}"/>
				</p:column>
				<p:column  style="text-align: center; width:30px;">
					<p:commandButton icon="ui-icon-pencil" update=":treeForm:treeTable :dialogTestForm:recordDialogId"  oncomplete="newLeafDialog.show();" 
					action="#{treeBean.editSuBomDetFromTree(suBomDetTreeNode)}" title="#{msg['editCurrentRecord']}" />
				</p:column>
				<p:column style="text-align: center; width:30px;">
					<p:commandButton icon="ui-icon-trash" onclick="deleteConfirmation.show()" action="#{treeBean.findSuBomDetIDFromNode(suBomDetTreeNode)}" process="@this"
					 update=":treeForm:treeTable :dialogTestForm:newLeafDialogDatas" title="#{msg['deleteCurrentRecord']}"/>
				</p:column>
			</p:treeTable>

TreeBean. java onNodeExpand :

Code: Select all


	public void onNodeExpand(NodeExpandEvent event) {
		List<TreeNode> childNodes = event.getTreeNode().getChildren();  
		for (TreeNode treeNode : childNodes) {
			SuBomDet sbd = new SuBomDet();
			SuBomDetTreeNode suBomDetTreeNode = (SuBomDetTreeNode) treeNode.getData();
			liste = bomMstService().findSuBomDetListByBomDetUpId(DataCriteria.create(sbd), suBomDetTreeNode.getBomDetID());
			for (SuBomDet suBomDet : liste) { 
				TreeNode documents = new DefaultTreeNode(new SuBomDetTreeNode(suBomDet.getBomId(), suBomDet.getBomDetId(), suBomDet.getSku(), suBomDet.getDetDesc(),
						suBomDet.getValidFrom(),
						suBomDet.getValidTo(),
						String.valueOf(suBomDet.getQty().doubleValue()) + " " +
								suBomDet.getCmpCode(), suBomDet.getBomDetUpId(), suBomDet.getBomLevel(), suBomDet.getDetType()), treeNode);
				

			}
		}
	}


kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

15 Oct 2014, 16:43

- Create a minimal but fully working example (xhtml AND java, (simple objects for tree etc) )
- Post version numbers...

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 40 guests