You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Chris Colman <ch...@stepaheadsoftware.com> on 2012/11/21 14:21:45 UTC

Wicket 6 changes to AjaxLink causing problem

I'm porting a large app from 1.5 to 1.6 and have come across a problem
with AjaxLinkS not triggering their onClick when inside components that
are added dynamically via an implementation of the IComponentResolver
interface.
 
I found this in the Wicket in Action book:
 

Event registration

Until version 1.5.x attaching an Ajax event behavior to a component
would lead to addition of an inline attribute to the markup of this
component. For example the produced markup for an AjaxLink is similar
to:
<a id="linkId" onclick="wicketAjaxGet('some/url')">Link</a>
In Wicket 6 JavaScript event registration is being used instead. For
example the above becomes:
<head>
  ...
  <script>
    Wicket.Event.add(window, 'domready', function(event) {
      Wicket.Ajax.get({'u': 'some/url', 'c': 'linkId', 'e': 'click'}));
      // ... more event registrations and onDomReady scripts
    });
  </script>
</head>
...
<a id="linkId">Link</a>
 
I'm assuming that, being generated in the <head> this event registration
code happens for all components that are added explicitly but not for
any components that are added dynamically by the component resolver. 
 
If this is correct, is it possible to get the event registration to
occur for dynamically added components? If not is it possibly that
dynamically added components could revert to working back in pre 1.6
mode? i.e.  the appropriate JS code is placed in the link itself:
 
<a id="linkId" onclick="wicketAjaxGet('some/url')">Link</a>
 
Regards,
Chris

RE: Wicket 6 changes to AjaxLink causing problem

Posted by Chris Colman <ch...@stepaheadsoftware.com>.
I've created a quickstart and provided it in:

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

Regards,
Chris

>-----Original Message-----
>From: Martin Grigorov [mailto:mgrigorov@apache.org]
>Sent: Thursday, 22 November 2012 12:38 AM
>To: users@wicket.apache.org
>Subject: Re: Wicket 6 changes to AjaxLink causing problem
>
>Hi,
>
>Can you show your code related to the issue ?
>
>
>On Wed, Nov 21, 2012 at 3:21 PM, Chris Colman
><ch...@stepaheadsoftware.com>wrote:
>
>> I'm porting a large app from 1.5 to 1.6 and have come across a
problem
>> with AjaxLinkS not triggering their onClick when inside components
that
>> are added dynamically via an implementation of the IComponentResolver
>> interface.
>>
>> I found this in the Wicket in Action book:
>>
>>
>> Event registration
>>
>> Until version 1.5.x attaching an Ajax event behavior to a component
>> would lead to addition of an inline attribute to the markup of this
>> component. For example the produced markup for an AjaxLink is similar
>> to:
>> <a id="linkId" onclick="wicketAjaxGet('some/url')">Link</a>
>> In Wicket 6 JavaScript event registration is being used instead. For
>> example the above becomes:
>> <head>
>>   ...
>>   <script>
>>     Wicket.Event.add(window, 'domready', function(event) {
>>       Wicket.Ajax.get({'u': 'some/url', 'c': 'linkId', 'e':
'click'}));
>>       // ... more event registrations and onDomReady scripts
>>     });
>>   </script>
>> </head>
>> ...
>> <a id="linkId">Link</a>
>>
>> I'm assuming that, being generated in the <head> this event
registration
>> code happens for all components that are added explicitly but not for
>> any components that are added dynamically by the component resolver.
>>
>> If this is correct, is it possible to get the event registration to
>> occur for dynamically added components? If not is it possibly that
>> dynamically added components could revert to working back in pre 1.6
>> mode? i.e.  the appropriate JS code is placed in the link itself:
>>
>> <a id="linkId" onclick="wicketAjaxGet('some/url')">Link</a>
>>
>> Regards,
>> Chris
>>
>
>
>
>--
>Martin Grigorov
>jWeekend
>Training, Consulting, Development
>http://jWeekend.com <http://jweekend.com/>

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


Re: Wicket 6 changes to AjaxLink causing problem

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

Can you show your code related to the issue ?


On Wed, Nov 21, 2012 at 3:21 PM, Chris Colman
<ch...@stepaheadsoftware.com>wrote:

> I'm porting a large app from 1.5 to 1.6 and have come across a problem
> with AjaxLinkS not triggering their onClick when inside components that
> are added dynamically via an implementation of the IComponentResolver
> interface.
>
> I found this in the Wicket in Action book:
>
>
> Event registration
>
> Until version 1.5.x attaching an Ajax event behavior to a component
> would lead to addition of an inline attribute to the markup of this
> component. For example the produced markup for an AjaxLink is similar
> to:
> <a id="linkId" onclick="wicketAjaxGet('some/url')">Link</a>
> In Wicket 6 JavaScript event registration is being used instead. For
> example the above becomes:
> <head>
>   ...
>   <script>
>     Wicket.Event.add(window, 'domready', function(event) {
>       Wicket.Ajax.get({'u': 'some/url', 'c': 'linkId', 'e': 'click'}));
>       // ... more event registrations and onDomReady scripts
>     });
>   </script>
> </head>
> ...
> <a id="linkId">Link</a>
>
> I'm assuming that, being generated in the <head> this event registration
> code happens for all components that are added explicitly but not for
> any components that are added dynamically by the component resolver.
>
> If this is correct, is it possible to get the event registration to
> occur for dynamically added components? If not is it possibly that
> dynamically added components could revert to working back in pre 1.6
> mode? i.e.  the appropriate JS code is placed in the link itself:
>
> <a id="linkId" onclick="wicketAjaxGet('some/url')">Link</a>
>
> Regards,
> Chris
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>