Sven,

" once rendering of components via Ajax has started, you cannot update 
components."

But at the moment when this happens, we are in the onConfigure() part of the 
lifecycle. Which is before onBeforeRender(), and hence components should've 
have started rendering... but that is minor as...

"You should just add all expanded nodes to your tree's model. That's faster and 
won't trigger any updates:"

Brilliant! I didn't realize that tree model was the *expanded* nodes, but it 
makes sense since you now say it...

Thanks! This works great and gets round any other issues. :)

Cheers,
Col.

-----Original Message-----
From: Sven Meier [mailto:s...@meiers.net]
Sent: Monday, December 9, 2013 8:01 PM
To: users@wicket.apache.org
Subject: Re: Components can no longer be added

Hi,

once rendering of components via Ajax has started, you cannot update components.

AbstractTree#expand() is a convenience method that updates the expanded branch 
automatically, hence you get the IllegalStateException.

You should just add all expanded nodes to your tree's model. That's faster and 
won't trigger any updates:

   tree.getModel().addAll(addNodes);

If you always start with all nodes expanded, you might want to use a custom 
set, which inverses its contents. See 
org.apache.wicket.examples.tree.FooExpansion for inspiration.

Regards
Sven


On 12/09/2013 06:28 AM, Colin Rogers wrote:
> Wicketeers,
>
> I have another hard-to-track down issue.
>
> To make matters worse, I've actually taken this code/pattern, put it
> into a quickstart - and what do you know - it works fine...! This
> means I have no way to recreate this error in a demonstrable way.
> Hopefully if I throw this out there, someone might be able to describe
> the error and I can then determine what I'm doing to cause it.
> Unfortunately google has zero results for;
>
> +"Components can no  longer be added" +wicket
>
> Anyway... the exception I'm getting is;
>
> java.lang.IllegalStateException: Components can no  longer be added
>       at 
> org.apache.wicket.ajax.AbstractAjaxResponse.assertNotFrozen(AbstractAjaxResponse.java:740)
>       at 
> org.apache.wicket.ajax.AbstractAjaxResponse.assertComponentsNotFrozen(AbstractAjaxResponse.java:733)
>       at 
> org.apache.wicket.ajax.AbstractAjaxResponse.add(AbstractAjaxResponse.java:358)
>       at 
> org.apache.wicket.ajax.AjaxRequestHandler.add(AjaxRequestHandler.java:239)
>       at 
> org.apache.wicket.ajax.AjaxRequestHandler.add(AjaxRequestHandler.java:232)
>       at 
> org.apache.wicket.extensions.markup.html.repeater.tree.TableTree.updateBranch(TableTree.java:178)
>       at 
> org.apache.wicket.extensions.markup.html.repeater.tree.AbstractTree.expand(AbstractTree.java:204)
>       at myapp.TreeUtils.expandNode(TreeUtils.java:25)
>       at myapp.TreeUtils.expandAll(TreeUtils.java:19)
>
>
> It is caused when refreshing a table-tree component, that had previous 
> rendered correctly and had successfully expanded the nodes. This problem 
> happens when the table-trees parent component is refreshed, in which the 
> table is rebuilt from new, and replaced the old table. Having debugged the 
> code, it's something to do with the AjaxRequestHandler that has been 
> retrieved - in that it's components are 'frozen'. It's odd as I'm in  the 
> onConfigure() part of the lifecycle, and therefore components should be okay 
> to be added - especially as they are brand new components. Could the 
> AjaxRequestHandler being retrieved be the wrong one, stale one?
>
> List I said - I can't recreate it in a Quickstart, so there is obviously 
> something else in the 100k+s of the projects code that is doing something 
> else to mess it up.
>
> The 'Tree Utils' class looks like this;
>
> public class TreeUtils {
>
>      @SuppressWarnings("unchecked")
>      public static void expandAll( AbstractTree<?> tree ) {
>
>          // stupid cast!! Has to happen for use to retrieve the roots, 
> generically.
>          AbstractTree<Object> castTree = (AbstractTree<Object>) tree;
>
>          Iterator<?> roots = tree.getProvider().getRoots();
>          while( roots.hasNext() ) {
>
>              Object root = roots.next();
>              expandNode( castTree, root );
>          }
>      }
>
>      private static void expandNode( AbstractTree<Object> tree, Object
> node) {
>
>          tree.expand(node);
>
>          Iterator<?> children = tree.getProvider().getChildren(node);
>          while( children.hasNext() ) {
>
>              Object child = children.next();
>              expandNode( tree, child );
>          }
>      }
> }
>
>
> Any pointers and tips would be greatly appreciated.
>
> Cheers,
> Col.
> EMAIL DISCLAIMER This email message and its attachments are confidential and 
> may also contain copyright or privileged material. If you are not the 
> intended recipient, you may not forward the email or disclose or use the 
> information contained in it. If you have received this email message in 
> error, please advise the sender immediately by replying to this email and 
> delete the message and any associated attachments. Any views, opinions, 
> conclusions, advice or statements expressed in this email message are those 
> of the individual sender and should not be relied upon as the considered 
> view, opinion, conclusions, advice or statement of this company except where 
> the sender expressly, and with authority, states them to be the considered 
> view, opinion, conclusions, advice or statement of this company. Every care 
> is taken but we recommend that you scan any attachments for viruses.
>


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

EMAIL DISCLAIMER This email message and its attachments are confidential and 
may also contain copyright or privileged material. If you are not the intended 
recipient, you may not forward the email or disclose or use the information 
contained in it. If you have received this email message in error, please 
advise the sender immediately by replying to this email and delete the message 
and any associated attachments. Any views, opinions, conclusions, advice or 
statements expressed in this email message are those of the individual sender 
and should not be relied upon as the considered view, opinion, conclusions, 
advice or statement of this company except where the sender expressly, and with 
authority, states them to be the considered view, opinion, conclusions, advice 
or statement of this company. Every care is taken but we recommend that you 
scan any attachments for viruses.

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

Reply via email to