You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by massimo_pugni <ma...@alice.it> on 2011/05/01 13:27:40 UTC

Re: wicket-tree checkboxes managing

Hi Sven,
I'm on back on it now.
To hidden the checkboxes for roots I've put the 'if' into the
'newContentComponent' method

something like this
public Component newContentComponent(String id, final AbstractTree<Skill>
tree, IModel<Skill> model)
	{
		if (model.getObject().isRoot()) {
			return new Label(id, model);
		} else {
			return new CheckedFolder<Skill>(id, tree, model)
			{ ... }

What I'd like to do now is to reproduce 'check all/uncheck all' features I
was able to do using a linear/plain list view data structure (the original
structure I'd like to replace with a hierarchical one)

best
massimo
--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/wicket-tree-checkboxes-managing-tp3472967p3487626.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: wicket-tree checkboxes managing

Posted by Sven Meier <sv...@meiers.net>.
Hi Massimo,

children of collapsed nodes are not present in the Wicket component 
hierarchy. I don't understand why you're getting different results 
whether you want to select or deselect though.

Instead of twiddling with components, you should perform the mutation 
directly on your model objects:

     root.selectAll(true):

     public void selectAll(boolean select) {
       this.selected = select;

       for (Foo child : children) {
          child.selectAll(select);
       }
    }

Hope this helps

Sven

On 05/21/2011 08:45 AM, massimo_pugni wrote:
> Hi,
> now that all is looking fine I'm observing a strange behaviuor.
> The same method, to 'check/uncheck' all from a button,
>
> public void modifyAllCheckBoxes(final boolean select) {
>          visitChildren(CheckBox.class, new IVisitor<Component>() {
>              @Override
>              public Object component(Component component) {
>                  CheckBox checkBox=(CheckBox)component;
>                  checkBox.setModelObject(select);
>                  return IVisitor.CONTINUE_TRAVERSAL;
>              }
>          });
>       }
> 	
> seems not working when all are collapsed and if I want unselect all (the
> select works).
> 	1.	Collapsing all and selecting all works
> 	2.	nodes into a branch can be unselected with the button only after having
> expanded and collapsed it
> 	
> 	page is opened with the tree state = expanded by default
> 	
> 	best
> 	Massimo
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/wicket-tree-checkboxes-managing-tp3472967p3540207.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: wicket-tree checkboxes managing

Posted by massimo_pugni <ma...@alice.it>.
Hi,
now that all is looking fine I'm observing a strange behaviuor.
The same method, to 'check/uncheck' all from a button,

public void modifyAllCheckBoxes(final boolean select) {
        visitChildren(CheckBox.class, new IVisitor<Component>() {
            @Override
            public Object component(Component component) {
                CheckBox checkBox=(CheckBox)component;
                checkBox.setModelObject(select);
                return IVisitor.CONTINUE_TRAVERSAL;
            }
        });
     }
	 
seems not working when all are collapsed and if I want unselect all (the
select works). 
	1.	Collapsing all and selecting all works
	2.	nodes into a branch can be unselected with the button only after having
expanded and collapsed it
	
	page is opened with the tree state = expanded by default
	
	best
	Massimo

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/wicket-tree-checkboxes-managing-tp3472967p3540207.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: wicket-tree checkboxes managing

Posted by Sven Meier <sv...@meiers.net>.
Hi,

I just rechecked the source of FormComponentPanel and there's nothing in 
there which could have any effect on the tree.
Sorry, but I don't have any clue what might be going wrong here.

Sven

On 05/05/2011 09:14 PM, massimo_pugni wrote:
> hello Sven,
> the branch just collapsed.
>
> After a tab switching the tree is rightly loaded into its collapsed state
> (active arrows + labels) and the same thing does not happen replacing the
> 'extends FormComponentPanel' with 'extends Panel'. I must add that the
> application is very complex and the tree structure is a nested data
> structure within a tabbed page (that is actually a Panel).
>
> I'd like make use of a 'FormComponentPanel' because I think it's easier to
> perform an update of the model (every tab switching is a save to persist
> data).
>
> wicket version is the 1.4.9 and the tree package I'm using is is the 0.4.4
>
> kind regards Sven
> Massimo
>
>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/wicket-tree-checkboxes-managing-tp3472967p3499223.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: wicket-tree checkboxes managing

Posted by massimo_pugni <ma...@alice.it>.
hello Sven,
the branch just collapsed.

After a tab switching the tree is rightly loaded into its collapsed state
(active arrows + labels) and the same thing does not happen replacing the
'extends FormComponentPanel' with 'extends Panel'. I must add that the
application is very complex and the tree structure is a nested data
structure within a tabbed page (that is actually a Panel).

I'd like make use of a 'FormComponentPanel' because I think it's easier to
perform an update of the model (every tab switching is a save to persist
data).

wicket version is the 1.4.9 and the tree package I'm using is is the 0.4.4

kind regards Sven
Massimo



--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/wicket-tree-checkboxes-managing-tp3472967p3499223.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: wicket-tree checkboxes managing

Posted by Sven Meier <sv...@meiers.net>.
Hi Massimo,

for the tree it doesn't matter which component it is contained in.
There must be another change causing this.

 >why do I get the branches (second level) lost

What is lost, the complete branch or is the branch just collapsed?

Best regards

Sven


Am 05.05.2011 17:36, schrieb massimo_pugni:
> Hi Sven,
> I'm slowly moving forward and now loading a 2-levels checked selectable tree
> within a panel hosted by tabbed page and so on.
> The only significant changes I did are related to the model and the data
> providing but a question:
>
> why do I get the branches (second level) lost the second time I enter the
> tab contaning the tree
> when loading the tree itself into a 'formComponentPanel'?
>
> The same thing doesn't happen using a simple 'Panel' instead of a
> 'formComponentPanel', do you have already experimented something like this?
>
> best
> Massimo
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/wicket-tree-checkboxes-managing-tp3472967p3498667.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: wicket-tree checkboxes managing

Posted by massimo_pugni <ma...@alice.it>.
Hi Sven,
I'm slowly moving forward and now loading a 2-levels checked selectable tree
within a panel hosted by tabbed page and so on.
The only significant changes I did are related to the model and the data
providing but a question:

why do I get the branches (second level) lost the second time I enter the
tab contaning the tree 
when loading the tree itself into a 'formComponentPanel'?

The same thing doesn't happen using a simple 'Panel' instead of a
'formComponentPanel', do you have already experimented something like this?

best
Massimo

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/wicket-tree-checkboxes-managing-tp3472967p3498667.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: wicket-tree checkboxes managing

Posted by Sven Meier <sv...@meiers.net>.
Hi,

you can utilize the usual Check/CheckGroup/CheckGroupSelector 
combination. I've added a convenience CheckContent implementation 
recently (now for Wicket 1.4 too):

   
http://code.google.com/p/wicket-tree/source/browse/branches/wicket-tree-0.4.x/wicket-tree/src/main/java/wickettree/content/CheckFolder.java

Hope this helps

Sven

On 05/01/2011 01:27 PM, massimo_pugni wrote:
> Hi Sven,
> I'm on back on it now.
> To hidden the checkboxes for roots I've put the 'if' into the
> 'newContentComponent' method
>
> something like this
> public Component newContentComponent(String id, final AbstractTree<Skill>
> tree, IModel<Skill>  model)
> 	{
> 		if (model.getObject().isRoot()) {
> 			return new Label(id, model);
> 		} else {
> 			return new CheckedFolder<Skill>(id, tree, model)
> 			{ ... }
>
> What I'd like to do now is to reproduce 'check all/uncheck all' features I
> was able to do using a linear/plain list view data structure (the original
> structure I'd like to replace with a hierarchical one)
>
> best
> massimo
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/wicket-tree-checkboxes-managing-tp3472967p3487626.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org