Sorry, I mis-filed it. I saw this as a variation of bug 32 and added a comment on there (dated 5/3/2006). I just looked at the bug tracker and realized that bug had been long-closed. Do you want to reopen 32 or should I re-file?
-Steve -----Original Message----- From: Jesse Kuhnert [mailto:[EMAIL PROTECTED] Sent: Friday, June 30, 2006 10:48 AM To: Tapestry users Subject: Re: Tree w/Checkbox on each node--Way to Fix Indent? Is there an open issue for this in tacos? Seems like a big enough deal thing that I should fix it. http://tacoscomponents.jot.com/BugReporter On 6/30/06, Steve Shucker <[EMAIL PROTECTED]> wrote: > > I had this problem a while ago and traced it to a PartialFor component > within the tree that was persisting the contents incorrectly in the form. > It's using an iterator that doesn't track depth. As a workaround, you can > create your own html/jwc files for the Tree control (use taco's backing > class) and add a volatile=true property to the PartialFor component. It's > not ideal, but it's working great for me. > > -Steve > > -----Original Message----- > From: Tyrone Hed [mailto:[EMAIL PROTECTED] > Sent: Thursday, June 29, 2006 9:57 PM > To: users@tapestry.apache.org > Subject: Tree w/Checkbox on each node--Way to Fix Indent? > > > > Folks, > I have developed a Tapestry app (4.0.1) that uses the Tree in > four > places. It works great in three of those places but not in the one that > includes a checkbox on each node of the tree. The problem is that it loses > track of the indent and gives all nodes of the tree the same indent as the > right-most node. So, as the user opens each node, the tree marches from > left > to right. In short, it looks like hell. I've looked at the generated > source > but it just piles on divs and spans to get the indent. The margin indent, > in > short, is broken when you have to enclose a tree in a FORM. Any > suggestions? > Here is my code. > Thank you, > > Ty > > > Files included: > > userEnterprises.page > userEnterprises.html > UserEnterprises.java > > ------------------------------------------------------------------- > userEnterprises.page > ------------------------------------------------------------------- > > <page-specification > class="com.tyco.web.pages.authorization.UserEnterprises"> > > <description>Tree</description> > <property name="item" /> > <bean name="evenOdd" class="org.apache.tapestry.bean.EvenOdd"/> > > <component id="tree" type="tacos:Tree"> > <binding name="value" value="item"/> > <binding name="nodeLinkAjax" value="ognl:false" /> > <binding name="evenOdd" value="ognl:page.beans.evenOdd" > /> > <binding name="rowStyle" value="ognl:beans.evenOdd"/> > <binding > name="state" value="enterpriseTreeState"/> > </component> > > <component id="submitEditUserUpdateEnterprises" type="ClickSubmit"> > <binding name="selected" value="submitAction"/> > <binding name="tag" value='"EDIT_USER_UPDATE_ENTERPRISES"'/> > </component> > > <component id="submitCancel" type="ClickSubmit"> > <binding name="selected" value="submitAction"/> > <binding name="tag" value='"CANCEL"'/> > </component> > > </page-specification> > > > ------------------------------------------------------------------- > userEnterprises.html > ------------------------------------------------------------------- > > <table width="90%" class="body" border="1"> > <TR> > <TD> > <div > jwcid="tree" > id="tree" > keyProvider="ognl:keyProvider" > contentProvider="ognl:contentProvider" > > style="overflow: auto; width: auto; height: auto;"> > <span jwcid="@If" condition="ognl:item.id" > conditionValue="true"> > <input jwcid="[EMAIL PROTECTED]" > value="ognl:item.checked" /> > </span> > <span jwcid="@If" condition="ognl:item.active" > conditionValue="ognl:true"> > <span style="color:black"><span jwcid="@Insert" > value="ognl:item.name"/></span> > </span> > <span jwcid="@Else"> > <span style="color:gray"><span jwcid="@Insert" > value="ognl:item.name"/></span> > </span> > </div> > </TD> > </TR> > </TABLE> > > > ------------------------------------------------------------------- > UserEnterprises.java > > (I doubt this class will we useful in solving this problem > but just in case I am doing so for completeness.) > ------------------------------------------------------------------- > > /* > * Created on Jan 17, 2006 > * > * Copyright 2005 Ingenix, Inc. All rights reserved. > * This file contains CONFIDENTIAL and PROPRIETARY information > * and should not be distributed without prior written permission. > */ > package com.ingenix.freya.web.pages.authorization; > > import java.util.ArrayList; > import java.util.HashSet; > import java.util.Iterator; > import java.util.List; > import java.util.Set; > > import org.apache.commons.logging.Log; > import org.apache.commons.logging.LogFactory; > import org.apache.tapestry.IRequestCycle; > import org.apache.tapestry.annotations.InjectState; > import org.apache.tapestry.event.PageBeginRenderListener; > import org.apache.tapestry.event.PageEvent; > > import com.tyco.api.authorization.AuthorizationFactory; > import com.tyco.api.authorization.User; > import com.tyco.api.enterprise.Enterprise; > import > com.tyco.web.components.authorization.AuthenticationListComponentBase; > import com.tyco.web.components.enterprise.EnterpriseTreeContentProvider; > import com.tyco.web.components.enterprise.Folder; > import com.tyco.web.components.enterprise.Item; > > public abstract class UserEnterprises extends UserControllerPage > implements > PageBeginRenderListener > { > private List mPermissions; > private Enterprise mEnterprise; > > @InjectState( "contentProvider" ) > public abstract EnterpriseTreeContentProvider getContentProvider(); > public abstract void setContentProvider( EnterpriseTreeContentProvider > pEnterpriseTreeContentProvider ); > > @InjectState( "enterpriseTreeState" ) > public abstract Set<Long> getEnterpriseTreeState(); > public abstract void setEnterpriseTreeState( Set pEnterpriseTreeState ); > > @InjectState("newUser") > public abstract User getNewUser(); > public abstract void setNewUser(User val); > > public abstract Long getID(); > > protected Log mLog = LogFactory.getLog(this.getClass().getName()); > > public void pageBeginRender(PageEvent pEvent) > { > detectCheckedEnterprises( getNewUser() ); > } > > public void activate(IRequestCycle pCycle) > { > Object[] parameters = pCycle.getListenerParameters(); > > if (parameters.length >= 2) > { > Long userID = (Long) parameters[1]; > User user = > getAuthorizationService().getUserByID(userID); > setNewUser(user); > List permissionList = getUserPermissions(user); > setPermissions(permissionList); > } > // If Errors found then we need to keep user data with the error for > redisplay > else if ((getErrorMessage() == null) && (getPasswordError() == > null)) > { > setNewUser(AuthorizationFactory.newUser()); > } > } > > /** > * Although the superclass has its own save() method, > * we need to override it here so that we can get capture > * the checked enterprises. It is critical that we do not > * execute the superclass save(). > */ > public void save() > { > IRequestCycle pCycle = this.getRequestCycle(); > > if( ACTION_EDIT_USER_UPDATE_ENTERPRISES.equals( getSubmitAction() ) ) > { > EnterpriseTreeContentProvider contentProvider = > getContentProvider(); > List treeRoots = contentProvider.getTreeRoots(); > List<Long> enterpriseIds = determineCheckedEnterprises( treeRoots ); > > if( this.getRequestCycle().isRewinding() ) > { > getAuthorizationService().assignEnterprisesToUser( enterpriseIds, > getNewUser().getID() ); > Long idOfUpdatedUser = getNewUser().getID(); > User updatedUser = getAuthorizationService().getUserByID( > idOfUpdatedUser ); > setNewUser( updatedUser ); > > pCycle.activate( AuthenticationListComponentBase.TARGET_EDIT_USER); > } > } > else if( ACTION_CANCEL.equals( getSubmitAction() ) ) > { > pCycle.activate( AuthenticationListComponentBase.TARGET_EDIT_USER ); > } > > } > > public List<Long> determineCheckedEnterprises( List pTreeRoots ) > { > List<Long> checkedEnterprises = new ArrayList<Long>(); > > addChildNodes( pTreeRoots, checkedEnterprises ); > > return checkedEnterprises; > } > > > public void addChildNodes( List pFolderItems, List<Long> > pCheckedEnterprises ) > { > Iterator iterator = pFolderItems.iterator(); > while( iterator.hasNext() ) > { > Object obj = iterator.next(); > if( obj instanceof Folder ) > { > Folder folder = (Folder) obj; > if( folder.isChecked() ) > { > String stringID = folder.getId(); > pCheckedEnterprises.add( new Long( stringID ) ); > } > List folderItems = folder.getItems(); > List folderFolders = folder.getFolders(); > > if( folderItems.size() > 0 ) > { > addChildNodes( folderItems, pCheckedEnterprises ); > } > if( folderFolders.size() > 0 ) > { > addChildNodes( folderFolders, pCheckedEnterprises ); > } > } > else if( obj instanceof Item ) > { > Item item = (Item) obj; > if( item.isChecked() ) > { > String stringID = item.getId(); > pCheckedEnterprises.add( new Long( stringID ) ); > } > } > } > } > > > public Enterprise getEnterprise() > { > return mEnterprise; > } > public void setEnterprise( Enterprise pEnterprise ) > { > mEnterprise = pEnterprise; > } > > public List getPermissions() > { > if (mPermissions == null) > { > mPermissions = new ArrayList(); > } > return mPermissions; > } > public void setPermissions(List pPermissions) > { > mPermissions = pPermissions; > } > > > > public void detectCheckedEnterprises( User pUser ) > { > EnterpriseTreeContentProvider tree = getContentProvider(); > if( tree == null ) > { > initializeEnterpriseTreeContentProvider( getNewUser() ); > tree = getContentProvider(); > } > > // First, compile a Set of the user's enterprises > List userEnts = pUser.getEnterprises(); > if( userEnts == null || userEnts.size() == 0) > { > return; > } > > Iterator userIt = userEnts.iterator(); > Set<String> userEntSet = new HashSet<String>(); > while( userIt.hasNext() ) > { > Enterprise userEnt = (Enterprise) userIt.next(); > userEntSet.add( userEnt.getName() ); > } > > // Next, go through the entepriseTree and display the user's checked > enteprises > List treeRoots = tree.getTreeRoots(); > Iterator it = treeRoots.iterator(); > > while( it.hasNext() ) > { > Object obj = it.next(); > > if( obj instanceof Folder ) > { > Folder aFolder = (Folder) obj; > String folderName = aFolder.getName(); > > if( userEntSet.contains( folderName ) ) > { > aFolder.setChecked( true ); > } > checkChildNodes( aFolder, userEntSet ); > > } > else if( obj instanceof Item ) > { > Item anItem = (Item) obj; > String itemName = anItem.getName(); > > if( userEntSet.contains( itemName ) ) > { > anItem.setChecked( true ); > } > } > } > } > > public void checkChildNodes( Folder pFolder, Set pUserEntSet ) > { > List items = pFolder.getItems(); > Iterator it = items.iterator(); > > while( it.hasNext() ) > { > Item anItem = (Item) it.next(); > if( pUserEntSet.contains( anItem.getName() ) ) > { > anItem.setChecked( true ); > } > } > > List folders = pFolder.getFolders(); > Iterator itF = folders.iterator(); > > while( itF.hasNext() ) > { > Folder aFolder = (Folder) itF.next(); > if( pUserEntSet.contains( aFolder.getName() ) ) > { > aFolder.setChecked( true ); > } > checkChildNodes( aFolder, pUserEntSet ); > } > } > > /** This method added to assist mock testing. */ > public User getUserByID( Long pUserID ) > { > return getAuthorizationService().getUserByID( pUserID ); > } > } > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Jesse Kuhnert Tacos/Tapestry, team member/developer Open source based consulting work centered around dojo/tapestry/tacos/hivemind. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]