You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Alexander Elsholz <al...@widas.de> on 2009/06/14 13:43:43 UTC

DOJO Menu Items and AJAX-Target-Components

Hi,

i use dojo menues in my application and mostly it works fine. but when an other
ajax-call refreshed menu's target component the menu will not be displayed. it
seams, that the markup-id of wicket-component changed after ajax-refresh and so
the dojo-js cannot find the menu item for this wicket-component.

had anybody the same problem?

when not what could be the problem?

thanks alex


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


RE: DOJO Menu Items and AJAX-Target-Components

Posted by Stefan Lindner <li...@visionet.de>.
Yes Igor, we do this. But this seems not tob e sufficient for some java libraries. The first time (after the initial page load) everything works. But after an Ajax call (where the <head> section is present in the Ajax response) the behavior is broken. Wat seems to work is to put the javascript stuff into the <body> tag using the onComponentRendered() method like

	JavascriptUtils.writeJavascript(RequestCycle.get().getResponse(), "my javascript");

-----Ursprüngliche Nachricht-----
Von: Igor Vaynberg [mailto:igor.vaynberg@gmail.com] 
Gesendet: Sonntag, 14. Juni 2009 18:42
An: users@wicket.apache.org
Betreff: Re: DOJO Menu Items and AJAX-Target-Components

your custom ajaxbehavior can implement iheadercontributor where you
can do response.appendjavascript to output a script that will be
processed in both regular requests and ajax requests alike.

-igor

On Sun, Jun 14, 2009 at 8:44 AM, Stefan Lindner<li...@visionet.de> wrote:
> Just playing around with current wicket 1.4 trunk.
> Having a a page with HTML like
>
>     <div wicket:id="someContainer">.......</div>
>     <a wicket:id="trigger">Test</a>
>
> and java like
>
>     final WebMarkupContainer container = new WebMarkupContainer("someContainer ");
>     container.addMarkupID true;
>     add(container);
>
>     add(new AjaxLink<Void>(" trigger ") {
>        @Override
>        public void onClick(AjaxRequestTarget target) {
>           container.testAjaxRefresh(target);
>        }
>     });
>
> Now deploying this in an application with AjaxDebugging set to true shows that the markup id does NOT change when the link is clicked.
>
> BUT
>
> Having a custom AjaxBehavior added to "container" depending on some free javscript libraries (e.g. Dojo, jQuery), the triggers get lost after the original HTML contet was replaced in DOM. In other words: the Ajax response replaces the original element and the functionality gets lost.
>
> If the custom AjaxBehavior coud re-act in seponse tot he Ajax call and reinstall the behavior, the custom AjaxBehavior could take care of this. But I can't see where this can bedone.
>
> This happens when the behavior is configured in the head section by calling somthing like this (jquery)
>
>     jQuery(function(){jquery('#markupID').doSomnething();});
>
> which means "after DOM has built, bind 'doSomething()' to Wicket Component 'markupID').
>
> If the behavior is configured in the body with a <script> section following the Wicket Component, this script eection is re-rendered in response to to the AjaxCall (in the on onComponentRendered() method) and the custom behavior is re-activated.
>
> Conclusion:
> If a javascript action is bound to some component and some trigger, a DOM replacement of this component (e.g. through an Ajax call with ing wicket via AjaxRequestTarget.addComponent()) diables the action and needs to be re-activated in the Ajax response.
>
> I don't know if this is the case in DOJO menu items (I think so when I'm looking at the old DOJO 0.4 implementation of drag and drop) but I see that I need to modify my impelmantation of jQuery integration into wicket (currently working on this, testet a seolution and proved it working).
>
> -----Ursprüngliche Nachricht-----
> Von: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
> Gesendet: Sonntag, 14. Juni 2009 16:43
> An: users@wicket.apache.org
> Betreff: Re: DOJO Menu Items and AJAX-Target-Components
>
> new markup id means you created new component instances. wicket does
> its best to try to preserver markup id - eg when you use replace or
> replacewith wicket will transfer new markupid of the component being
> replaced into the component it is being replaced with.
>
> if you need stable ids call setmarkupid() and propagate it to whatever
> hieararchy changes you are making. although for a menu it may help to
> use a non-volatile hierarchy since menus are usually static.
>
> -igor
>
> On Sun, Jun 14, 2009 at 7:09 AM, Stefan Lindner<li...@visionet.de> wrote:
>> Yes! "the markup-id of wicket-component changed after ajax-refresh" as you wrote.
>> I' looking for a solution for another javaxript library. Any hints from the Wicket gurus?
>>
>> -----Ursprüngliche Nachricht-----
>> Von: news [mailto:news@ger.gmane.org] Im Auftrag von Alexander Elsholz
>> Gesendet: Sonntag, 14. Juni 2009 13:44
>> An: users@wicket.apache.org
>> Betreff: DOJO Menu Items and AJAX-Target-Components
>>
>> Hi,
>>
>> i use dojo menues in my application and mostly it works fine. but when an other
>> ajax-call refreshed menu's target component the menu will not be displayed. it
>> seams, that the markup-id of wicket-component changed after ajax-refresh and so
>> the dojo-js cannot find the menu item for this wicket-component.
>>
>> had anybody the same problem?
>>
>> when not what could be the problem?
>>
>> thanks alex
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


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


Re: DOJO Menu Items and AJAX-Target-Components

Posted by Igor Vaynberg <ig...@gmail.com>.
your custom ajaxbehavior can implement iheadercontributor where you
can do response.appendjavascript to output a script that will be
processed in both regular requests and ajax requests alike.

-igor

On Sun, Jun 14, 2009 at 8:44 AM, Stefan Lindner<li...@visionet.de> wrote:
> Just playing around with current wicket 1.4 trunk.
> Having a a page with HTML like
>
>     <div wicket:id="someContainer">.......</div>
>     <a wicket:id="trigger">Test</a>
>
> and java like
>
>     final WebMarkupContainer container = new WebMarkupContainer("someContainer ");
>     container.addMarkupID true;
>     add(container);
>
>     add(new AjaxLink<Void>(" trigger ") {
>        @Override
>        public void onClick(AjaxRequestTarget target) {
>           container.testAjaxRefresh(target);
>        }
>     });
>
> Now deploying this in an application with AjaxDebugging set to true shows that the markup id does NOT change when the link is clicked.
>
> BUT
>
> Having a custom AjaxBehavior added to "container" depending on some free javscript libraries (e.g. Dojo, jQuery), the triggers get lost after the original HTML contet was replaced in DOM. In other words: the Ajax response replaces the original element and the functionality gets lost.
>
> If the custom AjaxBehavior coud re-act in seponse tot he Ajax call and reinstall the behavior, the custom AjaxBehavior could take care of this. But I can't see where this can bedone.
>
> This happens when the behavior is configured in the head section by calling somthing like this (jquery)
>
>     jQuery(function(){jquery('#markupID').doSomnething();});
>
> which means "after DOM has built, bind 'doSomething()' to Wicket Component 'markupID').
>
> If the behavior is configured in the body with a <script> section following the Wicket Component, this script eection is re-rendered in response to to the AjaxCall (in the on onComponentRendered() method) and the custom behavior is re-activated.
>
> Conclusion:
> If a javascript action is bound to some component and some trigger, a DOM replacement of this component (e.g. through an Ajax call with ing wicket via AjaxRequestTarget.addComponent()) diables the action and needs to be re-activated in the Ajax response.
>
> I don't know if this is the case in DOJO menu items (I think so when I'm looking at the old DOJO 0.4 implementation of drag and drop) but I see that I need to modify my impelmantation of jQuery integration into wicket (currently working on this, testet a seolution and proved it working).
>
> -----Ursprüngliche Nachricht-----
> Von: Igor Vaynberg [mailto:igor.vaynberg@gmail.com]
> Gesendet: Sonntag, 14. Juni 2009 16:43
> An: users@wicket.apache.org
> Betreff: Re: DOJO Menu Items and AJAX-Target-Components
>
> new markup id means you created new component instances. wicket does
> its best to try to preserver markup id - eg when you use replace or
> replacewith wicket will transfer new markupid of the component being
> replaced into the component it is being replaced with.
>
> if you need stable ids call setmarkupid() and propagate it to whatever
> hieararchy changes you are making. although for a menu it may help to
> use a non-volatile hierarchy since menus are usually static.
>
> -igor
>
> On Sun, Jun 14, 2009 at 7:09 AM, Stefan Lindner<li...@visionet.de> wrote:
>> Yes! "the markup-id of wicket-component changed after ajax-refresh" as you wrote.
>> I' looking for a solution for another javaxript library. Any hints from the Wicket gurus?
>>
>> -----Ursprüngliche Nachricht-----
>> Von: news [mailto:news@ger.gmane.org] Im Auftrag von Alexander Elsholz
>> Gesendet: Sonntag, 14. Juni 2009 13:44
>> An: users@wicket.apache.org
>> Betreff: DOJO Menu Items and AJAX-Target-Components
>>
>> Hi,
>>
>> i use dojo menues in my application and mostly it works fine. but when an other
>> ajax-call refreshed menu's target component the menu will not be displayed. it
>> seams, that the markup-id of wicket-component changed after ajax-refresh and so
>> the dojo-js cannot find the menu item for this wicket-component.
>>
>> had anybody the same problem?
>>
>> when not what could be the problem?
>>
>> thanks alex
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


RE: DOJO Menu Items and AJAX-Target-Components

Posted by Stefan Lindner <li...@visionet.de>.
Just playing around with current wicket 1.4 trunk.
Having a a page with HTML like

     <div wicket:id="someContainer">.......</div>
     <a wicket:id="trigger">Test</a>

and java like

     final WebMarkupContainer container = new WebMarkupContainer("someContainer ");
     container.addMarkupID true;
     add(container);

     add(new AjaxLink<Void>(" trigger ") {
        @Override
        public void onClick(AjaxRequestTarget target) {
           container.testAjaxRefresh(target);
        }
     });

Now deploying this in an application with AjaxDebugging set to true shows that the markup id does NOT change when the link is clicked.

BUT

Having a custom AjaxBehavior added to "container" depending on some free javscript libraries (e.g. Dojo, jQuery), the triggers get lost after the original HTML contet was replaced in DOM. In other words: the Ajax response replaces the original element and the functionality gets lost.

If the custom AjaxBehavior coud re-act in seponse tot he Ajax call and reinstall the behavior, the custom AjaxBehavior could take care of this. But I can't see where this can bedone.

This happens when the behavior is configured in the head section by calling somthing like this (jquery)

     jQuery(function(){jquery('#markupID').doSomnething();});

which means "after DOM has built, bind 'doSomething()' to Wicket Component 'markupID').

If the behavior is configured in the body with a <script> section following the Wicket Component, this script eection is re-rendered in response to to the AjaxCall (in the on onComponentRendered() method) and the custom behavior is re-activated.

Conclusion:
If a javascript action is bound to some component and some trigger, a DOM replacement of this component (e.g. through an Ajax call with ing wicket via AjaxRequestTarget.addComponent()) diables the action and needs to be re-activated in the Ajax response.

I don't know if this is the case in DOJO menu items (I think so when I'm looking at the old DOJO 0.4 implementation of drag and drop) but I see that I need to modify my impelmantation of jQuery integration into wicket (currently working on this, testet a seolution and proved it working).

-----Ursprüngliche Nachricht-----
Von: Igor Vaynberg [mailto:igor.vaynberg@gmail.com] 
Gesendet: Sonntag, 14. Juni 2009 16:43
An: users@wicket.apache.org
Betreff: Re: DOJO Menu Items and AJAX-Target-Components

new markup id means you created new component instances. wicket does
its best to try to preserver markup id - eg when you use replace or
replacewith wicket will transfer new markupid of the component being
replaced into the component it is being replaced with.

if you need stable ids call setmarkupid() and propagate it to whatever
hieararchy changes you are making. although for a menu it may help to
use a non-volatile hierarchy since menus are usually static.

-igor

On Sun, Jun 14, 2009 at 7:09 AM, Stefan Lindner<li...@visionet.de> wrote:
> Yes! "the markup-id of wicket-component changed after ajax-refresh" as you wrote.
> I' looking for a solution for another javaxript library. Any hints from the Wicket gurus?
>
> -----Ursprüngliche Nachricht-----
> Von: news [mailto:news@ger.gmane.org] Im Auftrag von Alexander Elsholz
> Gesendet: Sonntag, 14. Juni 2009 13:44
> An: users@wicket.apache.org
> Betreff: DOJO Menu Items and AJAX-Target-Components
>
> Hi,
>
> i use dojo menues in my application and mostly it works fine. but when an other
> ajax-call refreshed menu's target component the menu will not be displayed. it
> seams, that the markup-id of wicket-component changed after ajax-refresh and so
> the dojo-js cannot find the menu item for this wicket-component.
>
> had anybody the same problem?
>
> when not what could be the problem?
>
> thanks alex
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


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


Re: DOJO Menu Items and AJAX-Target-Components

Posted by Igor Vaynberg <ig...@gmail.com>.
well if the id doesnt change - eg you called setmarkupid and you do
not replace the component then i do not see what else wicket can do.
perhaps dojo keeps a direct reference to a dom node instead of just
the id - repainting the component will replace the dom node itself
which i guess may break the script.

-igor

On Sun, Jun 14, 2009 at 8:51 AM, Alexander
Elsholz<al...@widas.de> wrote:
> hi,
>
> i don't remove/add the components. the hierarchy is constant. its a
> very simple app:
>
> -> add an ajaxlink and change the attributemodifier of a panel
> -> add a menu item to the same panel
>
> after rerendering the panel (after link clicked) the menu will no
> more be displayed.
>
> i've the same problem in my table when using ajax and dojo menues
>
> i tried to set the markup-id manually, but no effect.
>
> the associated javascript uses the static markupid i set in code,
> but after rerendering the panel asynchron it does'nt work.
>
> alex
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


RE: Re: DOJO Menu Items and AJAX-Target-Components

Posted by Stefan Lindner <li...@visionet.de>.
Yes, that's what I wrote. The ID does not change but the response of the Ajax call replaces the original Wicket Component in THE DOM with a new Component WITH THE SAME ID but fresh on... events. So the original event behavior (e.g. menu display) gets lost. It needs tob e re-established in the Ajax resonse. For wicket events (bound to onclick e.g.) this is done when the comonent is written as a stream tot je Ajax response. Such an Ajax resonse looks like

	<component id="id1"  encoding="wicket1" ><![CDATA[<a class="draggableComponent" href="wicket:interface=:0:draggable1:draggableLink::ILinkListener::" style="display:block; height:80px; width:200px;" id="id1" onclick="var wcall=wicketAjaxGet('?wicket:interface=:0:draggable1:draggableLink::IBehaviorListener:0:-1',null,null, function() {return Wicket.$('id1') != null;}.bind(this));return !wcall;">
            I am draggable.<br/>
            <span style="font-size:110%; font-weight:bold;" id="id8">Drag me!</span>
            <br/>
            <span style="font-size:80%">(Or click me and see what happens...)</span>
            
        </a><script type="text/javascript" ><!--/*--><![CDATA[/*><!--*/


-----Ursprüngliche Nachricht-----
Von: news [mailto:news@ger.gmane.org] Im Auftrag von Alexander Elsholz
Gesendet: Sonntag, 14. Juni 2009 17:51
An: users@wicket.apache.org
Betreff: Re: DOJO Menu Items and AJAX-Target-Components

hi,

i don't remove/add the components. the hierarchy is constant. its a 
very simple app:

-> add an ajaxlink and change the attributemodifier of a panel
-> add a menu item to the same panel

after rerendering the panel (after link clicked) the menu will no
more be displayed.

i've the same problem in my table when using ajax and dojo menues

i tried to set the markup-id manually, but no effect.

the associated javascript uses the static markupid i set in code, 
but after rerendering the panel asynchron it does'nt work.

alex





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


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


Re: DOJO Menu Items and AJAX-Target-Components

Posted by Alexander Elsholz <al...@widas.de>.
hi,

i don't remove/add the components. the hierarchy is constant. its a 
very simple app:

-> add an ajaxlink and change the attributemodifier of a panel
-> add a menu item to the same panel

after rerendering the panel (after link clicked) the menu will no
more be displayed.

i've the same problem in my table when using ajax and dojo menues

i tried to set the markup-id manually, but no effect.

the associated javascript uses the static markupid i set in code, 
but after rerendering the panel asynchron it does'nt work.

alex





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


Re: DOJO Menu Items and AJAX-Target-Components

Posted by Igor Vaynberg <ig...@gmail.com>.
new markup id means you created new component instances. wicket does
its best to try to preserver markup id - eg when you use replace or
replacewith wicket will transfer new markupid of the component being
replaced into the component it is being replaced with.

if you need stable ids call setmarkupid() and propagate it to whatever
hieararchy changes you are making. although for a menu it may help to
use a non-volatile hierarchy since menus are usually static.

-igor

On Sun, Jun 14, 2009 at 7:09 AM, Stefan Lindner<li...@visionet.de> wrote:
> Yes! "the markup-id of wicket-component changed after ajax-refresh" as you wrote.
> I' looking for a solution for another javaxript library. Any hints from the Wicket gurus?
>
> -----Ursprüngliche Nachricht-----
> Von: news [mailto:news@ger.gmane.org] Im Auftrag von Alexander Elsholz
> Gesendet: Sonntag, 14. Juni 2009 13:44
> An: users@wicket.apache.org
> Betreff: DOJO Menu Items and AJAX-Target-Components
>
> Hi,
>
> i use dojo menues in my application and mostly it works fine. but when an other
> ajax-call refreshed menu's target component the menu will not be displayed. it
> seams, that the markup-id of wicket-component changed after ajax-refresh and so
> the dojo-js cannot find the menu item for this wicket-component.
>
> had anybody the same problem?
>
> when not what could be the problem?
>
> thanks alex
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


AW: DOJO Menu Items and AJAX-Target-Components

Posted by Stefan Lindner <li...@visionet.de>.
Yes! "the markup-id of wicket-component changed after ajax-refresh" as you wrote.
I' looking for a solution for another javaxript library. Any hints from the Wicket gurus?

-----Ursprüngliche Nachricht-----
Von: news [mailto:news@ger.gmane.org] Im Auftrag von Alexander Elsholz
Gesendet: Sonntag, 14. Juni 2009 13:44
An: users@wicket.apache.org
Betreff: DOJO Menu Items and AJAX-Target-Components

Hi,

i use dojo menues in my application and mostly it works fine. but when an other
ajax-call refreshed menu's target component the menu will not be displayed. it
seams, that the markup-id of wicket-component changed after ajax-refresh and so
the dojo-js cannot find the menu item for this wicket-component.

had anybody the same problem?

when not what could be the problem?

thanks alex


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


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