You can avoid this exception making sure to remove the tab from your panel
before the request cycle enter in RESPOND step.

On Fri, Sep 25, 2009 at 9:05 AM, Jens Zastrow <m...@jens-zastrow.de> wrote:

> Hi,
>
> The TabbedPanel internaly uses a Loop to render the tab-components. During
> a normla GET request the Loop.onPopulate() method ensures that all the
> loop-childs are removed before adding them again
> to support a possible change of teh underlying Integer-model.
>
> Loop.onPopulate()
> @Override
>   protected final void onPopulate()
>   {
>       // Remove any previous loop contents
>       removeAll();
>
>       // Get number of iterations
>       final int iterations = getIterations();
>       if (iterations > 0)
>       {
>           // Create LoopItems for each iteration
>           for (int iteration = 0; iteration < iterations; iteration++)
>           {
>               // Create item for loop iteration
>               LoopItem item = newItem(iteration);
>
>               // Add and populate item
>               add(item);
>               populateItem(item);
>           }
>       }
> }
>
> The TabbedPanel creates the following LoopItem which access the ITab-List
> directly.
>
> return new LoopItem(tabIndex)
>       {
>           private static final long serialVersionUID = 1L;
>
>           @Override
>           protected void onComponentTag(ComponentTag tag){...}
>
>           @Override
>           public boolean isVisible() {
>               // direct access of the tab
>               return getTabs().get(tabIndex).isVisible();
>           }
>       };
>
> The problem now is, if the tabs-list is modfied for example deleted, the
> onPopulate() method NEEDs to be invoked before
> the LoopItem.isVisible() the ensure that the old-Loop-childs (LoopItem) are
> deleted.
> This does not happen (Why?) if the TabbedPanel is added/updated in an
> ajax-call, resulting in ArrayIndexOufBounds-Exception
> in the LoopItem.isVisible() Method. (tabs.get(tabIndex)).
>
> My workaround currently is to invoke the onPopulate() manually during
> deletion (by beforeRender()).
>
> ((MarkupContainer)temporalTabs.get("tabs-container")).get("tabs").beforeRender();
>
> Any Ideas, how to force the onPopulate() get called - maybe invoking
> modelChanged() on some component???
>
> Thanks
> Jens
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>


-- 
Pedro Henrique Oliveira dos Santos

Reply via email to