Re: Remove Child in IVisitor causes problems

2010-12-04 Thread jbrookover

My first JIRA issue for Wicket!

https://issues.apache.org/jira/browse/WICKET-3229

Thanks,

Jake
-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Remove-Child-in-IVisitor-causes-problems-tp3071290p3072421.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Remove Child in IVisitor causes problems

2010-12-03 Thread jbrookover

Hey all, 

Interesting thing I encountered today.  I have a Panel that provides it's
own markupstream that is dynamically created from XML/XSLT.  Essentially, it
scans the markup stream for wicket:ids and then calls a
getWicketComponent(String wicketId) that generates different components
based on the id prefix (e.g. wicket:id=addContentBar_3).  Recently, I've
been wanting to redraw this panel via AJAX, changing the markup and adding
and removing child components accordingly.

Haven't had much trouble up to this point until I tried to remove multiple
stale components (e.g. a component that was generated from the previous
markup but doesn't exist in the new markup).  I tried to use an IVisitor..

visitChildren(new IVisitorComponent() {
  public Object component(Component component) {
if (/* component is stale */)
  component.remove();
return CONTINUE_TRAVERSAL_BUT_DONT_GO_DEEPER;
}

I discovered that IVisitor just does a simple run through an array and
removing the component adjusted the size/count of the array, messing up the
traversal and preventing other components from being removed.

I've solved this by just keeping a list of stale components and removing
them after the traversal, but it seems like their should either be
documentation/warnings about modifying the child list in a Visitor and/or a
change in the implementation to support this?  An iterator?  It's probably
rare enough that documentation would suffice :)

I'm just happy that Wicket has allowed me to do the niftiness I described
above :)

Jake
-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Remove-Child-in-IVisitor-causes-problems-tp3071290p3071290.html
Sent from the Users forum mailing list archive at Nabble.com.

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



Re: Remove Child in IVisitor causes problems

2010-12-03 Thread Igor Vaynberg
please create a jira issue to add the warning.

-igor

On Fri, Dec 3, 2010 at 8:10 AM, jbrookover jbrooko...@cast.org wrote:

 Hey all,

 Interesting thing I encountered today.  I have a Panel that provides it's
 own markupstream that is dynamically created from XML/XSLT.  Essentially, it
 scans the markup stream for wicket:ids and then calls a
 getWicketComponent(String wicketId) that generates different components
 based on the id prefix (e.g. wicket:id=addContentBar_3).  Recently, I've
 been wanting to redraw this panel via AJAX, changing the markup and adding
 and removing child components accordingly.

 Haven't had much trouble up to this point until I tried to remove multiple
 stale components (e.g. a component that was generated from the previous
 markup but doesn't exist in the new markup).  I tried to use an IVisitor..

 visitChildren(new IVisitorComponent() {
  public Object component(Component component) {
    if (/* component is stale */)
      component.remove();
    return CONTINUE_TRAVERSAL_BUT_DONT_GO_DEEPER;
 }

 I discovered that IVisitor just does a simple run through an array and
 removing the component adjusted the size/count of the array, messing up the
 traversal and preventing other components from being removed.

 I've solved this by just keeping a list of stale components and removing
 them after the traversal, but it seems like their should either be
 documentation/warnings about modifying the child list in a Visitor and/or a
 change in the implementation to support this?  An iterator?  It's probably
 rare enough that documentation would suffice :)

 I'm just happy that Wicket has allowed me to do the niftiness I described
 above :)

 Jake
 --
 View this message in context: 
 http://apache-wicket.1842946.n4.nabble.com/Remove-Child-in-IVisitor-causes-problems-tp3071290p3071290.html
 Sent from the Users forum mailing list archive at Nabble.com.

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



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