You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Maxim Solodovnik <so...@gmail.com> on 2017/01/13 18:15:41 UTC

Reload TabbedPanel preserving active tab

Hello Sebastien,

Is there any option to update TabbedPanel preserving active tab?
Both
tabs.reload(handler)
and
handler.add(tabs)

resets active tab :(((

or maybe if TabbedPanel was created as follows:
new TabbedPanel("tabs", Arrays.asList(userTab, fileTab)).*setActiveTab*(0)
it will be "re-assirned" on reload?

-- 
WBR
Maxim aka solomax

Re: Reload TabbedPanel preserving active tab

Posted by Maxim Solodovnik <so...@gmail.com>.
I see :)
I have removed "form" dialog from the tab
Maybe this report will help other users :)

Thanks for the hints :)

On Tue, Jan 17, 2017 at 6:35 PM, Sebastien <se...@gmail.com> wrote:

> Hi Maxim,
>
> It seems that the dialog widget is not correctly *destroyed*, therefore the
> new dialog that come in replacement cannot be re-wired.
>
> You can put a breakpoint in JQueryDestroyListener#onBeforeRespond to see
> whether the dialog is taken into account in the destroy process. (I guess
> not, because only directly targeted component are referenced here IIRC)
> You can also look in the ajax-debug-window if you see the
> jQuery('#mydialog').destroy() statement in the "priority-evaluate" section
> (I guess not, too)
>
> Otherwise, you have other workarounds:
> 1/ removing the dialog from the tab-panel :)
> 2/ calling mydialog#destroy *before* the ajax call (tough an
> AjaxCallListener, see #updateAjaxAttributes)
> 3/ calling mydialog#destroy in the response, trough
> handler.prependJavaScript(JQueryUtils.trycatch("jQuery('
> #mydialog').destroy()"));
> - I would opt for this one. you can look at [1]
>
> Hope this helps,
> Sebastien.
>
> [1]
> https://github.com/sebfz1/wicket-jquery-ui/blob/master/
> wicket-jquery-ui/src/main/java/com/googlecode/wicket/
> jquery/ui/JQueryUIBehavior.java#L136
>
>
>
> On Tue, Jan 17, 2017 at 11:50 AM, Maxim Solodovnik <so...@gmail.com>
> wrote:
>
> > Hello Sebastien,
> >
> > I'm using jquery TabbedPanel.
> > One of the panels contains jquery dialog with simple form (text field and
> > one of the dialog buttons works as submit)
> > I'm now getting weird component has been removed from page errors
> > It seems
> >
> > tabs.reload(handler);
> >
> > re-creates the panel, but doesn't re-create dialog :(
> > (dialog seems to be added to the <body> as hidden div, and not being
> > updated)
> >
> > Is it possible?
> > Are there any workarounds except removing dialog from the tab-panel?
> >
> >
> >
> > On Sun, Jan 15, 2017 at 12:30 AM, Sebastien <se...@gmail.com> wrote:
> >
> > > Transferring to users@, I did not realized I reply to you only
> Maxim...
> > >
> > >
> > > ---------- Forwarded message ----------
> > > From: Maxim Solodovnik <so...@gmail.com>
> > > Date: Sat, Jan 14, 2017 at 5:13 PM
> > > Subject: Re: Reload TabbedPanel preserving active tab
> > > To: Sebastien <se...@gmail.com>
> > >
> > >
> > > Thanks a lot Sebastien!
> > > Works as expected :)
> > >
> > > On Sat, Jan 14, 2017 at 8:31 PM, Sebastien <se...@gmail.com> wrote:
> > >
> > > > Oops, forgot something in the copy paste:
> > > >
> > > >         this.tabPanel = new TabbedPanel("tabs", this.newTabModel()) {
> > > >>
> > > >>             private IModel<Integer> indexModel = Model.of(-1);
> > > >>
> > > >>             @Override
> > > >>             protected void onConfigure()
> > > >>             {
> > > >>                 super.onConfigure();
> > > >>
> > > >>                 int index = indexModel.getObject();
> > > >>
> > > >>                 if (index > -1) // TODO eventually also check if the
> > > >> corresponding tab is visible
> > > >>                 {
> > > >>                     this.setActiveTab(index);
> > > >>                 }
> > > >>             }
> > > >>
> > > >>             public void onActivate(AjaxRequestTarget target, int
> > index,
> > > >> ITab tab)
> > > >>             {
> > > >>                 indexModel.setObject(index);
> > > >>             }
> > > >>         }
> > > >>
> > > >
> > > >
> > >
> > >
> > >
> > > --
> > > WBR
> > > Maxim aka solomax
> > >
> >
> >
> >
> > --
> > WBR
> > Maxim aka solomax
> >
>



-- 
WBR
Maxim aka solomax

Re: Reload TabbedPanel preserving active tab

Posted by Sebastien <se...@gmail.com>.
Hi Maxim,

It seems that the dialog widget is not correctly *destroyed*, therefore the
new dialog that come in replacement cannot be re-wired.

You can put a breakpoint in JQueryDestroyListener#onBeforeRespond to see
whether the dialog is taken into account in the destroy process. (I guess
not, because only directly targeted component are referenced here IIRC)
You can also look in the ajax-debug-window if you see the
jQuery('#mydialog').destroy() statement in the "priority-evaluate" section
(I guess not, too)

Otherwise, you have other workarounds:
1/ removing the dialog from the tab-panel :)
2/ calling mydialog#destroy *before* the ajax call (tough an
AjaxCallListener, see #updateAjaxAttributes)
3/ calling mydialog#destroy in the response, trough
handler.prependJavaScript(JQueryUtils.trycatch("jQuery('#mydialog').destroy()"));
- I would opt for this one. you can look at [1]

Hope this helps,
Sebastien.

[1]
https://github.com/sebfz1/wicket-jquery-ui/blob/master/wicket-jquery-ui/src/main/java/com/googlecode/wicket/jquery/ui/JQueryUIBehavior.java#L136



On Tue, Jan 17, 2017 at 11:50 AM, Maxim Solodovnik <so...@gmail.com>
wrote:

> Hello Sebastien,
>
> I'm using jquery TabbedPanel.
> One of the panels contains jquery dialog with simple form (text field and
> one of the dialog buttons works as submit)
> I'm now getting weird component has been removed from page errors
> It seems
>
> tabs.reload(handler);
>
> re-creates the panel, but doesn't re-create dialog :(
> (dialog seems to be added to the <body> as hidden div, and not being
> updated)
>
> Is it possible?
> Are there any workarounds except removing dialog from the tab-panel?
>
>
>
> On Sun, Jan 15, 2017 at 12:30 AM, Sebastien <se...@gmail.com> wrote:
>
> > Transferring to users@, I did not realized I reply to you only Maxim...
> >
> >
> > ---------- Forwarded message ----------
> > From: Maxim Solodovnik <so...@gmail.com>
> > Date: Sat, Jan 14, 2017 at 5:13 PM
> > Subject: Re: Reload TabbedPanel preserving active tab
> > To: Sebastien <se...@gmail.com>
> >
> >
> > Thanks a lot Sebastien!
> > Works as expected :)
> >
> > On Sat, Jan 14, 2017 at 8:31 PM, Sebastien <se...@gmail.com> wrote:
> >
> > > Oops, forgot something in the copy paste:
> > >
> > >         this.tabPanel = new TabbedPanel("tabs", this.newTabModel()) {
> > >>
> > >>             private IModel<Integer> indexModel = Model.of(-1);
> > >>
> > >>             @Override
> > >>             protected void onConfigure()
> > >>             {
> > >>                 super.onConfigure();
> > >>
> > >>                 int index = indexModel.getObject();
> > >>
> > >>                 if (index > -1) // TODO eventually also check if the
> > >> corresponding tab is visible
> > >>                 {
> > >>                     this.setActiveTab(index);
> > >>                 }
> > >>             }
> > >>
> > >>             public void onActivate(AjaxRequestTarget target, int
> index,
> > >> ITab tab)
> > >>             {
> > >>                 indexModel.setObject(index);
> > >>             }
> > >>         }
> > >>
> > >
> > >
> >
> >
> >
> > --
> > WBR
> > Maxim aka solomax
> >
>
>
>
> --
> WBR
> Maxim aka solomax
>

Re: Reload TabbedPanel preserving active tab

Posted by Maxim Solodovnik <so...@gmail.com>.
Hello Sebastien,

I'm using jquery TabbedPanel.
One of the panels contains jquery dialog with simple form (text field and
one of the dialog buttons works as submit)
I'm now getting weird component has been removed from page errors
It seems

tabs.reload(handler);

re-creates the panel, but doesn't re-create dialog :(
(dialog seems to be added to the <body> as hidden div, and not being
updated)

Is it possible?
Are there any workarounds except removing dialog from the tab-panel?



On Sun, Jan 15, 2017 at 12:30 AM, Sebastien <se...@gmail.com> wrote:

> Transferring to users@, I did not realized I reply to you only Maxim...
>
>
> ---------- Forwarded message ----------
> From: Maxim Solodovnik <so...@gmail.com>
> Date: Sat, Jan 14, 2017 at 5:13 PM
> Subject: Re: Reload TabbedPanel preserving active tab
> To: Sebastien <se...@gmail.com>
>
>
> Thanks a lot Sebastien!
> Works as expected :)
>
> On Sat, Jan 14, 2017 at 8:31 PM, Sebastien <se...@gmail.com> wrote:
>
> > Oops, forgot something in the copy paste:
> >
> >         this.tabPanel = new TabbedPanel("tabs", this.newTabModel()) {
> >>
> >>             private IModel<Integer> indexModel = Model.of(-1);
> >>
> >>             @Override
> >>             protected void onConfigure()
> >>             {
> >>                 super.onConfigure();
> >>
> >>                 int index = indexModel.getObject();
> >>
> >>                 if (index > -1) // TODO eventually also check if the
> >> corresponding tab is visible
> >>                 {
> >>                     this.setActiveTab(index);
> >>                 }
> >>             }
> >>
> >>             public void onActivate(AjaxRequestTarget target, int index,
> >> ITab tab)
> >>             {
> >>                 indexModel.setObject(index);
> >>             }
> >>         }
> >>
> >
> >
>
>
>
> --
> WBR
> Maxim aka solomax
>



-- 
WBR
Maxim aka solomax

Fwd: Reload TabbedPanel preserving active tab

Posted by Sebastien <se...@gmail.com>.
Transferring to users@, I did not realized I reply to you only Maxim...


---------- Forwarded message ----------
From: Maxim Solodovnik <so...@gmail.com>
Date: Sat, Jan 14, 2017 at 5:13 PM
Subject: Re: Reload TabbedPanel preserving active tab
To: Sebastien <se...@gmail.com>


Thanks a lot Sebastien!
Works as expected :)

On Sat, Jan 14, 2017 at 8:31 PM, Sebastien <se...@gmail.com> wrote:

> Oops, forgot something in the copy paste:
>
>         this.tabPanel = new TabbedPanel("tabs", this.newTabModel()) {
>>
>>             private IModel<Integer> indexModel = Model.of(-1);
>>
>>             @Override
>>             protected void onConfigure()
>>             {
>>                 super.onConfigure();
>>
>>                 int index = indexModel.getObject();
>>
>>                 if (index > -1) // TODO eventually also check if the
>> corresponding tab is visible
>>                 {
>>                     this.setActiveTab(index);
>>                 }
>>             }
>>
>>             public void onActivate(AjaxRequestTarget target, int index,
>> ITab tab)
>>             {
>>                 indexModel.setObject(index);
>>             }
>>         }
>>
>
>



-- 
WBR
Maxim aka solomax

Re: Reload TabbedPanel preserving active tab

Posted by Maxim Solodovnik <so...@gmail.com>.
Jquery :)
Thaks a lot!

WBR, Maxim
(from mobile, sorry for the typos)

On Jan 14, 2017 01:30, "Sebastien" <se...@gmail.com> wrote:

> Hi Maxim,
>
> good question! i think we can do it, i will have a look tomorrow... jquery
> or kendo ?
>
> best regards,
> sebastien
>
>
> On Jan 13, 2017 19:15, "Maxim Solodovnik" <so...@gmail.com> wrote:
>
> Hello Sebastien,
>
> Is there any option to update TabbedPanel preserving active tab?
> Both
> tabs.reload(handler)
> and
> handler.add(tabs)
>
> resets active tab :(((
>
> or maybe if TabbedPanel was created as follows:
> new TabbedPanel("tabs", Arrays.asList(userTab, fileTab)).*setActiveTab*(0)
> it will be "re-assirned" on reload?
>
> --
> WBR
> Maxim aka solomax
>
>
>

Re: Reload TabbedPanel preserving active tab

Posted by Sebastien <se...@gmail.com>.
Hi Maxim,

good question! i think we can do it, i will have a look tomorrow... jquery
or kendo ?

best regards,
sebastien


On Jan 13, 2017 19:15, "Maxim Solodovnik" <so...@gmail.com> wrote:

Hello Sebastien,

Is there any option to update TabbedPanel preserving active tab?
Both
tabs.reload(handler)
and
handler.add(tabs)

resets active tab :(((

or maybe if TabbedPanel was created as follows:
new TabbedPanel("tabs", Arrays.asList(userTab, fileTab)).*setActiveTab*(0)
it will be "re-assirned" on reload?

-- 
WBR
Maxim aka solomax