You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Thorsten Scherler <th...@apache.org> on 2005/09/20 12:51:10 UTC

Tree widget example broken (was Re: svn commit: r289538)

El vie, 16-09-2005 a las 13:48 +0000, sylvain@apache.org escribió:
> Author: sylvain
> Date: Fri Sep 16 06:46:22 2005
> New Revision: 289538
> 
> URL: http://svn.apache.org/viewcvs?rev=289538&view=rev
> Log:
> Merge GSoC libraries and 2.1 branches

Hi sylvain, 
(this time copyn' paste) ;-)

Thanks for checkin in the form stuff. :) I just played around a wee bit
but the tree example are broken in 2.1.x.

I get:
Unknown kind of widget 'tree' at
file:/home/thorsten/apache/cocoon-2.1.x/build/webapp/samples/blocks/forms/forms/sampletree_model.xml:30:44 
context://samples/blocks/forms/forms/sampletree_model.xml - 30:44


Calling function do_sampleTree 
context://samples/blocks/forms/forms/sampletree_model.xml - 30:44
[CascadingException]
resource://org/apache/cocoon/forms/flow/javascript/Form.js - 47:-1

...
org.apache.avalon.framework.service.ServiceException: Non-existing
component for this hint (Key='tree')
	at org.apache.cocoon.forms.util.SimpleServiceSelector.select(SimpleServiceSelector.java:98)
	at org.apache.cocoon.forms.formmodel.AbstractWidgetDefinitionBuilder.buildAnotherWidgetDefinition(AbstractWidgetDefinitionBuilder.java:145)
	at org.apache.cocoon.forms.formmodel.AbstractContainerDefinitionBuilder.setupContainer(AbstractContainerDefinitionBuilder.java:60)

Can it be that there is still something missing?

salu2
-- 
thorsten

"Together we stand, divided we fall!" 
Hey you (Pink Floyd)


Re: Tree widget example broken (was Re: svn commit: r289538)

Posted by Thorsten Scherler <th...@apache.org>.
El mié, 21-09-2005 a las 23:40 +0200, Sylvain Wallez escribió:
> Thorsten Scherler wrote:
> 
> >Please stay with me and have a look at http://pastebin.com/370146. I
> >added a binding file and a custom binding containing above code, but how
> >can I now produce for each object a node?
> >+    /*
> >+     * How to produce for each object a new xml-node?
> >+     * Like <file>objs[1]</file>, <file>objs[2]</file>, ...
> >+     */
> >  
> >
> 
> The problem is that the binding you will want to do highly depends on 
> the TreeModel, i.e. the kind of objects returned by model.getNode(). We 
> could imagine to have something similar to the repeater binding, 
> executing child bindings for each of the selected paths.

I will have a look into the repeater binding and can hopefully come up
with a workable start for the tree binding. Thanks for all your help. I
will try something on the weekend.

salu2
-- 
thorsten

"Together we stand, divided we fall!" 
Hey you (Pink Floyd)


Re: Tree widget example broken (was Re: svn commit: r289538)

Posted by Sylvain Wallez <sy...@apache.org>.
Thorsten Scherler wrote:

>Please stay with me and have a look at http://pastebin.com/370146. I
>added a binding file and a custom binding containing above code, but how
>can I now produce for each object a node?
>+    /*
>+     * How to produce for each object a new xml-node?
>+     * Like <file>objs[1]</file>, <file>objs[2]</file>, ...
>+     */
>  
>

The problem is that the binding you will want to do highly depends on 
the TreeModel, i.e. the kind of objects returned by model.getNode(). We 
could imagine to have something similar to the repeater binding, 
executing child bindings for each of the selected paths.

Sylvain

-- 
Sylvain Wallez                        Anyware Technologies
http://people.apache.org/~sylvain     http://www.anyware-tech.com
Apache Software Foundation Member     Research & Technology Director


Re: Tree widget example broken (was Re: svn commit: r289538)

Posted by Thorsten Scherler <th...@apache.org>.
El mié, 21-09-2005 a las 18:20 +0200, Sylvain Wallez escribió:
> Thorsten Scherler wrote:
...
> >
> >It does not provide child widgets in the cforms definition but IMO each
> >node of the tree is an option. The file explorer example shows that
> >quite nice. You can select nodes and the selected nodes are stored in
> >the message, right?
> >  
> >
> 
> The tree widget keeps the paths of selected nodes, but not the nodes 
> themselves, to avoid keeping hard references on the tree model. You can 
> access the selection using tree.getSelectionPath (single selection) or 
> tree.getSelectionPaths (multiple selection).
> 
>  From a TreePath, you can then access the actual tree node using 
> tree.getModel().getNode(path).
> 
> >Now one way to have a binding example is to not use the message wigdet
> >but another widget where we store the selected option. Please have a
> >look at http://pastebin.com/370003.
> >  
> >
> 
> Didn't knew pastebin. Cool!

:) It is really handy. 

> 
> >>From there I would like to change the filesOption.setValue(...) in:
> >...
> > } else {
> >   messages.setValue(count + " files selected");
> >   filesOption.setValue(count + " files selected");
> > }
> >
> >to an array that is storing the "files.selectionPath" for all selected
> >files. From there we can extracted it in the binding again. Does that
> >makes sense?
> >  
> >
> 
> You actually don't need to update the array in the event listener. Just 
> use tree.getSelectionPaths() to get the full selection when you need to 
> perform your binding.

Ok.

> >I am still looking into a way how to get the selection to an array. Can
> >you point me to information about getting the event.source.selection
> >into an array?
> >  
> >
> 
> What about:
> 
>     TreePath[] paths = tree.getSelectionPaths();
>     Object[] objs = new Object[paths.length];
>     for (int i = 0; i < paths.length; i++) {
>         objs[i] = tree.getModel().getNode(paths[i]);
>     }
> 

Please stay with me and have a look at http://pastebin.com/370146. I
added a binding file and a custom binding containing above code, but how
can I now produce for each object a node?
+    /*
+     * How to produce for each object a new xml-node?
+     * Like <file>objs[1]</file>, <file>objs[2]</file>, ...
+     */

salu2
-- 
thorsten

"Together we stand, divided we fall!" 
Hey you (Pink Floyd)


Re: Tree widget example broken (was Re: svn commit: r289538)

Posted by Sylvain Wallez <sy...@apache.org>.
Thorsten Scherler wrote:

>El mar, 20-09-2005 a las 17:38 +0200, Sylvain Wallez escribió: 
>  
>
>>Thorsten Scherler wrote:
>>    
>>
>>>That is working fine. :) Very good stuff.
>>>
>>>Any hints how I can implement the binding?
>>>      
>>>
>>The tree widget currently doesn't have child widgets, so binding it 
>>doesn't really make sense.
>>    
>>
>
>It does not provide child widgets in the cforms definition but IMO each
>node of the tree is an option. The file explorer example shows that
>quite nice. You can select nodes and the selected nodes are stored in
>the message, right?
>  
>

The tree widget keeps the paths of selected nodes, but not the nodes 
themselves, to avoid keeping hard references on the tree model. You can 
access the selection using tree.getSelectionPath (single selection) or 
tree.getSelectionPaths (multiple selection).

 From a TreePath, you can then access the actual tree node using 
tree.getModel().getNode(path).

>Now one way to have a binding example is to not use the message wigdet
>but another widget where we store the selected option. Please have a
>look at http://pastebin.com/370003.
>  
>

Didn't knew pastebin. Cool!

>>>From there I would like to change the filesOption.setValue(...) in:
>...
> } else {
>   messages.setValue(count + " files selected");
>   filesOption.setValue(count + " files selected");
> }
>
>to an array that is storing the "files.selectionPath" for all selected
>files. From there we can extracted it in the binding again. Does that
>makes sense?
>  
>

You actually don't need to update the array in the event listener. Just 
use tree.getSelectionPaths() to get the full selection when you need to 
perform your binding.

>I am still looking into a way how to get the selection to an array. Can
>you point me to information about getting the event.source.selection
>into an array?
>  
>

What about:

    TreePath[] paths = tree.getSelectionPaths();
    Object[] objs = new Object[paths.length];
    for (int i = 0; i < paths.length; i++) {
        objs[i] = tree.getModel().getNode(paths[i]);
    }

>>What you should take a lot at though, is the TreeModel which is what 
>>should be provided by the application to fill the tree.
>>    
>>
>
>I looked at the $Sample and actually I am planning to use it in lenya to
>read in the sitetree.xml of a publication. I reckon I just need some
>small modifications.
>  
>

Great! This tree widget is very new, and just awaits users to express 
their needs!

Sylvain

-- 
Sylvain Wallez                        Anyware Technologies
http://people.apache.org/~sylvain     http://www.anyware-tech.com
Apache Software Foundation Member     Research & Technology Director


Re: Tree widget example broken (was Re: svn commit: r289538)

Posted by Thorsten Scherler <th...@apache.org>.
El mar, 20-09-2005 a las 17:38 +0200, Sylvain Wallez escribió: 
> Thorsten Scherler wrote:
> 
> >That is working fine. :) Very good stuff.
> >
> >Any hints how I can implement the binding?
> >  
> >
> 
> The tree widget currently doesn't have child widgets, so binding it 
> doesn't really make sense.

It does not provide child widgets in the cforms definition but IMO each
node of the tree is an option. The file explorer example shows that
quite nice. You can select nodes and the selected nodes are stored in
the message, right?

Now one way to have a binding example is to not use the message wigdet
but another widget where we store the selected option. Please have a
look at http://pastebin.com/370003.

>>From there I would like to change the filesOption.setValue(...) in:
...
 } else {
   messages.setValue(count + " files selected");
   filesOption.setValue(count + " files selected");
 }

to an array that is storing the "files.selectionPath" for all selected
files. From there we can extracted it in the binding again. Does that
makes sense?

I am still looking into a way how to get the selection to an array. Can
you point me to information about getting the event.source.selection
into an array?

> What you should take a lot at though, is the TreeModel which is what 
> should be provided by the application to fill the tree.

I looked at the $Sample and actually I am planning to use it in lenya to
read in the sitetree.xml of a publication. I reckon I just need some
small modifications. 

> Sylvain

Thanks again.
-- 
thorsten

"Together we stand, divided we fall!" 
Hey you (Pink Floyd)


Re: Tree widget example broken (was Re: svn commit: r289538)

Posted by Sylvain Wallez <sy...@apache.org>.
Thorsten Scherler wrote:

>That is working fine. :) Very good stuff.
>
>Any hints how I can implement the binding?
>  
>

The tree widget currently doesn't have child widgets, so binding it 
doesn't really make sense.

What you should take a lot at though, is the TreeModel which is what 
should be provided by the application to fill the tree.

Sylvain

-- 
Sylvain Wallez                        Anyware Technologies
http://people.apache.org/~sylvain     http://www.anyware-tech.com
Apache Software Foundation Member     Research & Technology Director


Re: Tree widget example broken (was Re: svn commit: r289538)

Posted by Thorsten Scherler <th...@apache.org>.
El mar, 20-09-2005 a las 14:43 +0200, Sylvain Wallez escribió:
> Thorsten Scherler wrote:
...
> >Can it be that there is still something missing?
> >  
> >
> 
> Yep: I forgot to add the declaration for this new widget in the 2.1 
> configuration files. Should be fixed now.
> 
> Sylvain

Thanks a million, Sylvain!

That is working fine. :) Very good stuff.

Any hints how I can implement the binding?

salu2
-- 
thorsten

"Together we stand, divided we fall!" 
Hey you (Pink Floyd)


Re: Tree widget example broken (was Re: svn commit: r289538)

Posted by Sylvain Wallez <sy...@apache.org>.
Thorsten Scherler wrote:

>El vie, 16-09-2005 a las 13:48 +0000, sylvain@apache.org escribió:
>  
>
>>Author: sylvain
>>Date: Fri Sep 16 06:46:22 2005
>>New Revision: 289538
>>
>>URL: http://svn.apache.org/viewcvs?rev=289538&view=rev
>>Log:
>>Merge GSoC libraries and 2.1 branches
>>    
>>
>
>Hi sylvain, 
>(this time copyn' paste) ;-)
>
>Thanks for checkin in the form stuff. :) I just played around a wee bit
>but the tree example are broken in 2.1.x.
>
>I get:
>Unknown kind of widget 'tree' at
>file:/home/thorsten/apache/cocoon-2.1.x/build/webapp/samples/blocks/forms/forms/sampletree_model.xml:30:44 
>context://samples/blocks/forms/forms/sampletree_model.xml - 30:44
>
>
>Calling function do_sampleTree 
>context://samples/blocks/forms/forms/sampletree_model.xml - 30:44
>[CascadingException]
>resource://org/apache/cocoon/forms/flow/javascript/Form.js - 47:-1
>
>...
>org.apache.avalon.framework.service.ServiceException: Non-existing
>component for this hint (Key='tree')
>	at org.apache.cocoon.forms.util.SimpleServiceSelector.select(SimpleServiceSelector.java:98)
>	at org.apache.cocoon.forms.formmodel.AbstractWidgetDefinitionBuilder.buildAnotherWidgetDefinition(AbstractWidgetDefinitionBuilder.java:145)
>	at org.apache.cocoon.forms.formmodel.AbstractContainerDefinitionBuilder.setupContainer(AbstractContainerDefinitionBuilder.java:60)
>
>Can it be that there is still something missing?
>  
>

Yep: I forgot to add the declaration for this new widget in the 2.1 
configuration files. Should be fixed now.

Sylvain

-- 
Sylvain Wallez                        Anyware Technologies
http://people.apache.org/~sylvain     http://www.anyware-tech.com
Apache Software Foundation Member     Research & Technology Director