hi,

it took me some hours to figure out, why i could not get the tree component to 
work properly. the component did not update the tree on any action.

i looked over some examples (i think the example provided with old 
tacos-version is way overloaded) and finally got a copy of andhots example 
working 
(http://andyhot.di.uoa.gr/blojsom/blog/default/java/2006/08/17/Tapestry-Building-Trees-with-Tacos-and-Annotations.html)

the only thing i did wrong was not to provide the right type of KeyProvider for 
my TreeContent. this is not obvious, cause this parameter is optional...

finally, this is my very simple demo-component:

html:

<div jwcid="@tacos:Tree" contentProvider="ognl:contentProvider" 
keyProvider="ognl:keyProvider" value="ognl:current" >
   <span jwcid="@Insert" value="ognl:current" />
</div>

java:

        public abstract File getCurrent();

        public ITreeContentProvider getContentProvider() {
                return new FileTreeProvider();
        }

        public IKeyProvider getKeyProvider() {
                return new IKeyProvider() {
                        public Serializable getKey(Object obj) {
                                return (File) obj;
                        }
                };
        }

public class FileTreeProvider implements ITreeContentProvider {

        public Collection getChildren(Object obj) {
                File f = (File) obj;
                File[] list = f.listFiles();
                return Arrays.asList(list);
        }

        public Object getParent(Object obj) {
                File f = (File) obj;
                return f.getParentFile();
        }

        public boolean hasChildren(Object obj) {
                File f = (File) obj;
                return f.listFiles() != null;
        }

        public List getElements() {
                File f = new File("/");
                File[] list = f.listFiles();
                return Arrays.asList(list);
        }
}

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to