You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "Soloschenko, Tobias" <To...@rewe-group.com> on 2014/07/18 13:57:24 UTC

Ajax update of container listview in a panel

Hello everyone,

maybe someone is so kind and explain how to replace / update a panel which contains wicket container via ajax. My LeftToolbarPanel is looking this way (The java class is a simple listview):
HTML:
                        <wicket:panel>
                                   <wicket:container wicket:id="toolbarleft">
                                               <wicket:container wicket:id="toolbarcomponentleft"/>
                                   </wicket:container>
                        </wicket:panel>
Java:
            ...
            public LeftToolbarPanel() {
                        super("toolbarleftpanel");
                        add(new ListView("toolbarleft", leftComponents) {
                                   private static final long serialVersionUID = -8612783439924112109L;

                                   @Override
                                   protected void populateItem(ListItem item) {
                                               item.add((Component) item.getModelObject());
                                   }
                        });
                        setOutputMarkupId(true);
                        setOutputMarkupPlaceholderTag(true);
...
and I want to replace / update it this way (toolbarLeft is the panel which was already rendered before with some other components not being valid anymore):

                               LeftToolbarPanel leftToolbarPanel = new LeftToolbarPanel();
                               toolbarLeft.replaceWith(leftToolbarPanel);
                               toolbarLeft = leftToolbarPanel;
                               target.add(toolbarLeft);

My problem is that the initial rendering is working without any problems I can add components to the toolbar on page reload / browser refresh, but the ajax replacement is failing with this error:

Last cause: Failed to handle: <wicket:container wicket:id="toolbarcomponentleft"/>. It might be that no resolver has been registered to handle this special tag. But it also could be that you declared wicket:id=toolbarcomponentleft in your markup, but that you either did not add the component to your page at all, or that the hierarchy does not match.

<wicket:container wicket:id="toolbarleft">
                <wicket:container wicket:id="toolbarcomponentleft"/>
            </wicket:container>

Kind regards and thanks in advance

Tobias

AW: Ajax update of container listview in a panel

Posted by "Soloschenko, Tobias" <To...@rewe-group.com>.
Hi Martin,

thanks for the fast answer. The LeftToolbarPanel is a Panel which is added within a page. It contains a ListView with the two container markups. The information in the brackets is wrong.

I solved the issue just some minutes ago. I was adding a component to the ListView, but used the wrong id and not "toolbarcomponentleft". 

So everything is working fine. The Panel with the ListView can be replaced without any problems. :-)

kind regards

Tobias

-----Ursprüngliche Nachricht-----
Von: Martin Grigorov [mailto:mgrigorov@apache.org] 
Gesendet: Freitag, 18. Juli 2014 15:20
An: users@wicket.apache.org
Betreff: Re: Ajax update of container listview in a panel [UNSIGNIERT]

Hi Tobias,


Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov


On Fri, Jul 18, 2014 at 2:57 PM, Soloschenko, Tobias < Tobias.Soloschenko@rewe-group.com> wrote:

> Hello everyone,
>
> maybe someone is so kind and explain how to replace / update a panel 
> which contains wicket container via ajax. My LeftToolbarPanel is 
> looking this way (The java class is a simple listview):
>

Can you confirm that LeftToolbarPanel is a ListView ?
It looks to me that it is a Panel.

If it is really a ListView then the answer is that you cannot repaint repeater components with AjaxRequestTarget. You need to repaint their parent.


> HTML:
>                         <wicket:panel>
>                                    <wicket:container 
> wicket:id="toolbarleft">
>                                                <wicket:container 
> wicket:id="toolbarcomponentleft"/>
>                                    </wicket:container>
>                         </wicket:panel>
> Java:
>             ...
>             public LeftToolbarPanel() {
>                         super("toolbarleftpanel");
>                         add(new ListView("toolbarleft", leftComponents) {
>                                    private static final long 
> serialVersionUID = -8612783439924112109L;
>
>                                    @Override
>                                    protected void 
> populateItem(ListItem
> item) {
>                                                item.add((Component) 
> item.getModelObject());
>                                    }
>                         });
>                         setOutputMarkupId(true);
>                         setOutputMarkupPlaceholderTag(true);
> ...
> and I want to replace / update it this way (toolbarLeft is the panel 
> which was already rendered before with some other components not being 
> valid
> anymore):
>
>                                LeftToolbarPanel leftToolbarPanel = new 
> LeftToolbarPanel();
>                                toolbarLeft.replaceWith(leftToolbarPanel);
>                                toolbarLeft = leftToolbarPanel;
>                                target.add(toolbarLeft);
>
> My problem is that the initial rendering is working without any 
> problems I can add components to the toolbar on page reload / browser 
> refresh, but the ajax replacement is failing with this error:
>
> Last cause: Failed to handle: <wicket:container 
> wicket:id="toolbarcomponentleft"/>. It might be that no resolver has 
> been registered to handle this special tag. But it also could be that 
> you declared wicket:id=toolbarcomponentleft in your markup, but that 
> you either did not add the component to your page at all, or that the 
> hierarchy does not match.
>
> <wicket:container wicket:id="toolbarleft">
>                 <wicket:container wicket:id="toolbarcomponentleft"/>
>             </wicket:container>
>
> Kind regards and thanks in advance
>
> Tobias
>

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


Re: Ajax update of container listview in a panel

Posted by Martin Grigorov <mg...@apache.org>.
Hi Tobias,


Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov


On Fri, Jul 18, 2014 at 2:57 PM, Soloschenko, Tobias <
Tobias.Soloschenko@rewe-group.com> wrote:

> Hello everyone,
>
> maybe someone is so kind and explain how to replace / update a panel which
> contains wicket container via ajax. My LeftToolbarPanel is looking this way
> (The java class is a simple listview):
>

Can you confirm that LeftToolbarPanel is a ListView ?
It looks to me that it is a Panel.

If it is really a ListView then the answer is that you cannot repaint
repeater components with AjaxRequestTarget. You need to repaint their
parent.


> HTML:
>                         <wicket:panel>
>                                    <wicket:container
> wicket:id="toolbarleft">
>                                                <wicket:container
> wicket:id="toolbarcomponentleft"/>
>                                    </wicket:container>
>                         </wicket:panel>
> Java:
>             ...
>             public LeftToolbarPanel() {
>                         super("toolbarleftpanel");
>                         add(new ListView("toolbarleft", leftComponents) {
>                                    private static final long
> serialVersionUID = -8612783439924112109L;
>
>                                    @Override
>                                    protected void populateItem(ListItem
> item) {
>                                                item.add((Component)
> item.getModelObject());
>                                    }
>                         });
>                         setOutputMarkupId(true);
>                         setOutputMarkupPlaceholderTag(true);
> ...
> and I want to replace / update it this way (toolbarLeft is the panel which
> was already rendered before with some other components not being valid
> anymore):
>
>                                LeftToolbarPanel leftToolbarPanel = new
> LeftToolbarPanel();
>                                toolbarLeft.replaceWith(leftToolbarPanel);
>                                toolbarLeft = leftToolbarPanel;
>                                target.add(toolbarLeft);
>
> My problem is that the initial rendering is working without any problems I
> can add components to the toolbar on page reload / browser refresh, but the
> ajax replacement is failing with this error:
>
> Last cause: Failed to handle: <wicket:container
> wicket:id="toolbarcomponentleft"/>. It might be that no resolver has been
> registered to handle this special tag. But it also could be that you
> declared wicket:id=toolbarcomponentleft in your markup, but that you either
> did not add the component to your page at all, or that the hierarchy does
> not match.
>
> <wicket:container wicket:id="toolbarleft">
>                 <wicket:container wicket:id="toolbarcomponentleft"/>
>             </wicket:container>
>
> Kind regards and thanks in advance
>
> Tobias
>