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 2014/10/22 10:27:10 UTC
create and triigger custom js event on element
Hello All,
I'm trying to migrate huge project from wicket 1.4 to wicket 6
In old code I have code like this:
DataView<ProjectListItem> listView = new
DataView<ProjectListItem>("projectList", sdp) {
protected void populateItem(final Item<ProjectListItem> item) {
item.add(new AjaxEventBehavior("doubleClickEvent") {
protected void onEvent(AjaxRequestTarget target) {
}
}
}
}
after this each table row generated has "doubleClickEvent" attribute with
callback and I has able to call it.
currently nothing is generated :( code like
"$('#rowId').trigger('doubleClickEvent');" also has no effect :(
what am I doing wrong?
ps I was unable to find guide on custom events :(
--
WBR
Maxim aka solomax
Re: create and triigger custom js event on element
Posted by Maxim Solodovnik <so...@gmail.com>.
It is old project .....
I don't really like to rewrite everything :)
On 22 October 2014 15:59, Martin Grigorov <mg...@apache.org> wrote:
> Yes, I guess.
>
> Just FYI: there is a standard 'dblclick' event too. I'm not sure why you
> needed a custom one.
>
> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov
>
> On Wed, Oct 22, 2014 at 11:56 AM, Maxim Solodovnik <so...@gmail.com>
> wrote:
>
> > I believe this is because "click" satisfies most of users :)
> >
> > Thanks for clarifications :)
> >
> > On 22 October 2014 15:52, Martin Grigorov <mg...@apache.org> wrote:
> >
> > > Sorry.
> > >
> > > This is Wicket's fault:
> > >
> > >
> >
> https://github.com/apache/wicket/blob/db5be6ab05545e1bb95f566c3aeb23e05cf93437/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java#L72
> > >
> > > I think I've read somewhere that the event names should be lower cased.
> > But
> > > now I see at http://api.jquery.com/on/ that they use
> "keydown.myPlugin"
> > as
> > > an example.
> > >
> > > So far there were no complains about this and I suggest to leave this
> as
> > is
> > > in 6.x and 7.x, and remove the lower-casing in 8.x.
> > >
> > > Martin Grigorov
> > > Wicket Training and Consulting
> > > https://twitter.com/mtgrigorov
> > >
> > > On Wed, Oct 22, 2014 at 11:40 AM, Maxim Solodovnik <
> solomax666@gmail.com
> > >
> > > wrote:
> > >
> > > > Thanks a lot Martin!
> > > >
> > > > The root cause is: event name is lowercased :(
> > > >
> > > > So this failed: $('#rowId').trigger('doubleClickEvent');
> > > > And this passed: $('#rowId').trigger('doubleclickevent');
> > > >
> > > >
> > > >
> > > > On 22 October 2014 15:32, Martin Grigorov <mg...@apache.org>
> > wrote:
> > > >
> > > > > Hi Maxim,
> > > > >
> > > > > Since version 6.0.0 Wicket uses JavaScript event registration
> instead
> > > of
> > > > > generating element attributes.
> > > > > So for each usage of AjaxEventBehavior (and its specializations)
> > Wicket
> > > > > will generate something like Wicket.Ajax.ajax({....})
> > > > >
> > > > > I think in your code you are missing: item.setOutputMarkupId(true).
> > > > > Make sure the HTML element for 'item' has a unique id and there is
> > > > > Wicket.Ajax.ajax({c: sameId, ...}) in the page content.
> > > > >
> > > > > Martin Grigorov
> > > > > Wicket Training and Consulting
> > > > > https://twitter.com/mtgrigorov
> > > > >
> > > > > On Wed, Oct 22, 2014 at 11:27 AM, Maxim Solodovnik <
> > > solomax666@gmail.com
> > > > >
> > > > > wrote:
> > > > >
> > > > > > Hello All,
> > > > > >
> > > > > > I'm trying to migrate huge project from wicket 1.4 to wicket 6
> > > > > >
> > > > > > In old code I have code like this:
> > > > > >
> > > > > > DataView<ProjectListItem> listView = new
> > > > > > DataView<ProjectListItem>("projectList", sdp) {
> > > > > > protected void populateItem(final Item<ProjectListItem>
> > item)
> > > {
> > > > > > item.add(new
> AjaxEventBehavior("doubleClickEvent") {
> > > > > > protected void onEvent(AjaxRequestTarget
> > > > > target) {
> > > > > > }
> > > > > > }
> > > > > > }
> > > > > > }
> > > > > >
> > > > > > after this each table row generated has "doubleClickEvent"
> > attribute
> > > > with
> > > > > > callback and I has able to call it.
> > > > > >
> > > > > > currently nothing is generated :( code like
> > > > > > "$('#rowId').trigger('doubleClickEvent');" also has no effect :(
> > > > > >
> > > > > > what am I doing wrong?
> > > > > >
> > > > > > ps I was unable to find guide on custom events :(
> > > > > >
> > > > > > --
> > > > > > WBR
> > > > > > Maxim aka solomax
> > > > > >
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > WBR
> > > > Maxim aka solomax
> > > >
> > >
> >
> >
> >
> > --
> > WBR
> > Maxim aka solomax
> >
>
--
WBR
Maxim aka solomax
Re: create and triigger custom js event on element
Posted by Martin Grigorov <mg...@apache.org>.
Yes, I guess.
Just FYI: there is a standard 'dblclick' event too. I'm not sure why you
needed a custom one.
Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov
On Wed, Oct 22, 2014 at 11:56 AM, Maxim Solodovnik <so...@gmail.com>
wrote:
> I believe this is because "click" satisfies most of users :)
>
> Thanks for clarifications :)
>
> On 22 October 2014 15:52, Martin Grigorov <mg...@apache.org> wrote:
>
> > Sorry.
> >
> > This is Wicket's fault:
> >
> >
> https://github.com/apache/wicket/blob/db5be6ab05545e1bb95f566c3aeb23e05cf93437/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java#L72
> >
> > I think I've read somewhere that the event names should be lower cased.
> But
> > now I see at http://api.jquery.com/on/ that they use "keydown.myPlugin"
> as
> > an example.
> >
> > So far there were no complains about this and I suggest to leave this as
> is
> > in 6.x and 7.x, and remove the lower-casing in 8.x.
> >
> > Martin Grigorov
> > Wicket Training and Consulting
> > https://twitter.com/mtgrigorov
> >
> > On Wed, Oct 22, 2014 at 11:40 AM, Maxim Solodovnik <solomax666@gmail.com
> >
> > wrote:
> >
> > > Thanks a lot Martin!
> > >
> > > The root cause is: event name is lowercased :(
> > >
> > > So this failed: $('#rowId').trigger('doubleClickEvent');
> > > And this passed: $('#rowId').trigger('doubleclickevent');
> > >
> > >
> > >
> > > On 22 October 2014 15:32, Martin Grigorov <mg...@apache.org>
> wrote:
> > >
> > > > Hi Maxim,
> > > >
> > > > Since version 6.0.0 Wicket uses JavaScript event registration instead
> > of
> > > > generating element attributes.
> > > > So for each usage of AjaxEventBehavior (and its specializations)
> Wicket
> > > > will generate something like Wicket.Ajax.ajax({....})
> > > >
> > > > I think in your code you are missing: item.setOutputMarkupId(true).
> > > > Make sure the HTML element for 'item' has a unique id and there is
> > > > Wicket.Ajax.ajax({c: sameId, ...}) in the page content.
> > > >
> > > > Martin Grigorov
> > > > Wicket Training and Consulting
> > > > https://twitter.com/mtgrigorov
> > > >
> > > > On Wed, Oct 22, 2014 at 11:27 AM, Maxim Solodovnik <
> > solomax666@gmail.com
> > > >
> > > > wrote:
> > > >
> > > > > Hello All,
> > > > >
> > > > > I'm trying to migrate huge project from wicket 1.4 to wicket 6
> > > > >
> > > > > In old code I have code like this:
> > > > >
> > > > > DataView<ProjectListItem> listView = new
> > > > > DataView<ProjectListItem>("projectList", sdp) {
> > > > > protected void populateItem(final Item<ProjectListItem>
> item)
> > {
> > > > > item.add(new AjaxEventBehavior("doubleClickEvent") {
> > > > > protected void onEvent(AjaxRequestTarget
> > > > target) {
> > > > > }
> > > > > }
> > > > > }
> > > > > }
> > > > >
> > > > > after this each table row generated has "doubleClickEvent"
> attribute
> > > with
> > > > > callback and I has able to call it.
> > > > >
> > > > > currently nothing is generated :( code like
> > > > > "$('#rowId').trigger('doubleClickEvent');" also has no effect :(
> > > > >
> > > > > what am I doing wrong?
> > > > >
> > > > > ps I was unable to find guide on custom events :(
> > > > >
> > > > > --
> > > > > WBR
> > > > > Maxim aka solomax
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > WBR
> > > Maxim aka solomax
> > >
> >
>
>
>
> --
> WBR
> Maxim aka solomax
>
Re: create and triigger custom js event on element
Posted by Maxim Solodovnik <so...@gmail.com>.
I believe this is because "click" satisfies most of users :)
Thanks for clarifications :)
On 22 October 2014 15:52, Martin Grigorov <mg...@apache.org> wrote:
> Sorry.
>
> This is Wicket's fault:
>
> https://github.com/apache/wicket/blob/db5be6ab05545e1bb95f566c3aeb23e05cf93437/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java#L72
>
> I think I've read somewhere that the event names should be lower cased. But
> now I see at http://api.jquery.com/on/ that they use "keydown.myPlugin" as
> an example.
>
> So far there were no complains about this and I suggest to leave this as is
> in 6.x and 7.x, and remove the lower-casing in 8.x.
>
> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov
>
> On Wed, Oct 22, 2014 at 11:40 AM, Maxim Solodovnik <so...@gmail.com>
> wrote:
>
> > Thanks a lot Martin!
> >
> > The root cause is: event name is lowercased :(
> >
> > So this failed: $('#rowId').trigger('doubleClickEvent');
> > And this passed: $('#rowId').trigger('doubleclickevent');
> >
> >
> >
> > On 22 October 2014 15:32, Martin Grigorov <mg...@apache.org> wrote:
> >
> > > Hi Maxim,
> > >
> > > Since version 6.0.0 Wicket uses JavaScript event registration instead
> of
> > > generating element attributes.
> > > So for each usage of AjaxEventBehavior (and its specializations) Wicket
> > > will generate something like Wicket.Ajax.ajax({....})
> > >
> > > I think in your code you are missing: item.setOutputMarkupId(true).
> > > Make sure the HTML element for 'item' has a unique id and there is
> > > Wicket.Ajax.ajax({c: sameId, ...}) in the page content.
> > >
> > > Martin Grigorov
> > > Wicket Training and Consulting
> > > https://twitter.com/mtgrigorov
> > >
> > > On Wed, Oct 22, 2014 at 11:27 AM, Maxim Solodovnik <
> solomax666@gmail.com
> > >
> > > wrote:
> > >
> > > > Hello All,
> > > >
> > > > I'm trying to migrate huge project from wicket 1.4 to wicket 6
> > > >
> > > > In old code I have code like this:
> > > >
> > > > DataView<ProjectListItem> listView = new
> > > > DataView<ProjectListItem>("projectList", sdp) {
> > > > protected void populateItem(final Item<ProjectListItem> item)
> {
> > > > item.add(new AjaxEventBehavior("doubleClickEvent") {
> > > > protected void onEvent(AjaxRequestTarget
> > > target) {
> > > > }
> > > > }
> > > > }
> > > > }
> > > >
> > > > after this each table row generated has "doubleClickEvent" attribute
> > with
> > > > callback and I has able to call it.
> > > >
> > > > currently nothing is generated :( code like
> > > > "$('#rowId').trigger('doubleClickEvent');" also has no effect :(
> > > >
> > > > what am I doing wrong?
> > > >
> > > > ps I was unable to find guide on custom events :(
> > > >
> > > > --
> > > > WBR
> > > > Maxim aka solomax
> > > >
> > >
> >
> >
> >
> > --
> > WBR
> > Maxim aka solomax
> >
>
--
WBR
Maxim aka solomax
Re: create and triigger custom js event on element
Posted by Martin Grigorov <mg...@apache.org>.
Sorry.
This is Wicket's fault:
https://github.com/apache/wicket/blob/db5be6ab05545e1bb95f566c3aeb23e05cf93437/wicket-core/src/main/java/org/apache/wicket/ajax/AjaxEventBehavior.java#L72
I think I've read somewhere that the event names should be lower cased. But
now I see at http://api.jquery.com/on/ that they use "keydown.myPlugin" as
an example.
So far there were no complains about this and I suggest to leave this as is
in 6.x and 7.x, and remove the lower-casing in 8.x.
Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov
On Wed, Oct 22, 2014 at 11:40 AM, Maxim Solodovnik <so...@gmail.com>
wrote:
> Thanks a lot Martin!
>
> The root cause is: event name is lowercased :(
>
> So this failed: $('#rowId').trigger('doubleClickEvent');
> And this passed: $('#rowId').trigger('doubleclickevent');
>
>
>
> On 22 October 2014 15:32, Martin Grigorov <mg...@apache.org> wrote:
>
> > Hi Maxim,
> >
> > Since version 6.0.0 Wicket uses JavaScript event registration instead of
> > generating element attributes.
> > So for each usage of AjaxEventBehavior (and its specializations) Wicket
> > will generate something like Wicket.Ajax.ajax({....})
> >
> > I think in your code you are missing: item.setOutputMarkupId(true).
> > Make sure the HTML element for 'item' has a unique id and there is
> > Wicket.Ajax.ajax({c: sameId, ...}) in the page content.
> >
> > Martin Grigorov
> > Wicket Training and Consulting
> > https://twitter.com/mtgrigorov
> >
> > On Wed, Oct 22, 2014 at 11:27 AM, Maxim Solodovnik <solomax666@gmail.com
> >
> > wrote:
> >
> > > Hello All,
> > >
> > > I'm trying to migrate huge project from wicket 1.4 to wicket 6
> > >
> > > In old code I have code like this:
> > >
> > > DataView<ProjectListItem> listView = new
> > > DataView<ProjectListItem>("projectList", sdp) {
> > > protected void populateItem(final Item<ProjectListItem> item) {
> > > item.add(new AjaxEventBehavior("doubleClickEvent") {
> > > protected void onEvent(AjaxRequestTarget
> > target) {
> > > }
> > > }
> > > }
> > > }
> > >
> > > after this each table row generated has "doubleClickEvent" attribute
> with
> > > callback and I has able to call it.
> > >
> > > currently nothing is generated :( code like
> > > "$('#rowId').trigger('doubleClickEvent');" also has no effect :(
> > >
> > > what am I doing wrong?
> > >
> > > ps I was unable to find guide on custom events :(
> > >
> > > --
> > > WBR
> > > Maxim aka solomax
> > >
> >
>
>
>
> --
> WBR
> Maxim aka solomax
>
Re: create and triigger custom js event on element
Posted by Maxim Solodovnik <so...@gmail.com>.
Thanks a lot Martin!
The root cause is: event name is lowercased :(
So this failed: $('#rowId').trigger('doubleClickEvent');
And this passed: $('#rowId').trigger('doubleclickevent');
On 22 October 2014 15:32, Martin Grigorov <mg...@apache.org> wrote:
> Hi Maxim,
>
> Since version 6.0.0 Wicket uses JavaScript event registration instead of
> generating element attributes.
> So for each usage of AjaxEventBehavior (and its specializations) Wicket
> will generate something like Wicket.Ajax.ajax({....})
>
> I think in your code you are missing: item.setOutputMarkupId(true).
> Make sure the HTML element for 'item' has a unique id and there is
> Wicket.Ajax.ajax({c: sameId, ...}) in the page content.
>
> Martin Grigorov
> Wicket Training and Consulting
> https://twitter.com/mtgrigorov
>
> On Wed, Oct 22, 2014 at 11:27 AM, Maxim Solodovnik <so...@gmail.com>
> wrote:
>
> > Hello All,
> >
> > I'm trying to migrate huge project from wicket 1.4 to wicket 6
> >
> > In old code I have code like this:
> >
> > DataView<ProjectListItem> listView = new
> > DataView<ProjectListItem>("projectList", sdp) {
> > protected void populateItem(final Item<ProjectListItem> item) {
> > item.add(new AjaxEventBehavior("doubleClickEvent") {
> > protected void onEvent(AjaxRequestTarget
> target) {
> > }
> > }
> > }
> > }
> >
> > after this each table row generated has "doubleClickEvent" attribute with
> > callback and I has able to call it.
> >
> > currently nothing is generated :( code like
> > "$('#rowId').trigger('doubleClickEvent');" also has no effect :(
> >
> > what am I doing wrong?
> >
> > ps I was unable to find guide on custom events :(
> >
> > --
> > WBR
> > Maxim aka solomax
> >
>
--
WBR
Maxim aka solomax
Re: create and triigger custom js event on element
Posted by Martin Grigorov <mg...@apache.org>.
Hi Maxim,
Since version 6.0.0 Wicket uses JavaScript event registration instead of
generating element attributes.
So for each usage of AjaxEventBehavior (and its specializations) Wicket
will generate something like Wicket.Ajax.ajax({....})
I think in your code you are missing: item.setOutputMarkupId(true).
Make sure the HTML element for 'item' has a unique id and there is
Wicket.Ajax.ajax({c: sameId, ...}) in the page content.
Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov
On Wed, Oct 22, 2014 at 11:27 AM, Maxim Solodovnik <so...@gmail.com>
wrote:
> Hello All,
>
> I'm trying to migrate huge project from wicket 1.4 to wicket 6
>
> In old code I have code like this:
>
> DataView<ProjectListItem> listView = new
> DataView<ProjectListItem>("projectList", sdp) {
> protected void populateItem(final Item<ProjectListItem> item) {
> item.add(new AjaxEventBehavior("doubleClickEvent") {
> protected void onEvent(AjaxRequestTarget target) {
> }
> }
> }
> }
>
> after this each table row generated has "doubleClickEvent" attribute with
> callback and I has able to call it.
>
> currently nothing is generated :( code like
> "$('#rowId').trigger('doubleClickEvent');" also has no effect :(
>
> what am I doing wrong?
>
> ps I was unable to find guide on custom events :(
>
> --
> WBR
> Maxim aka solomax
>