Re: Global Ajax Event Handler

2014-09-10 Thread Martin Grigorov
Tobias sent me a quickstart app.

TestPage is stateless and thus never stored in the storages.
Just add setStatelessHint(false) to its constructor and the problem
disappears.

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


On Tue, Sep 9, 2014 at 10:10 PM, Tobias Soloschenko 
tobiassolosche...@googlemail.com wrote:

 The usecase requires it :-) I send an example to you.

 I hope this will be possible because then you are also able to do ajax
 requests from embedded jsp files. :-D

 thanks anyway!

  Am 09.09.2014 um 16:29 schrieb Richter, Marvin 
 marvin.rich...@freenetdigital.com:
 
  That definitely sounds like a really odd use case or am I wrong?
 
  Do you really want to generate the URL outside from the Wicket context?
  I mean this is something which is heavily tied to wicket anyway so why
 not generating it inside it's context?
  And where do you need/use the final generated URL? I guess inside the
 Wicket context ...
 
  Maybe you should rethinking your use case, I bet the problem you're
 trying to solve can be solved much, much easier!
 
  Anyway .. wish you luck ;)
 
  -Original Message-
  From: Tobias Soloschenko [mailto:tobiassolosche...@googlemail.com]
  Sent: Tuesday, September 09, 2014 2:58 PM
  To: users@wicket.apache.org
  Subject: Re: Global Ajax Event Handler
 
  Thats the point. It is not used within a Component / Behavior - so I
 cant use getPage() ...
 
  Am 09.09.2014 um 14:50 schrieb Martin Grigorov mgrigo...@apache.org:
 
  The UrlGenerator class is used somewhere where the Page is available,
 no ?
  In SomeComponent/SomeBehavior:
 
  UrlGenerator generator = new UrlGenerator(); Url url =
  generator.generate(getPage().getPageId());
 
  Session.get().getPageManager().getPage(exisingAndNonExpiredPageId) is
  the way to get a reference to the page.
  Wicket uses this API internally every time you click a link or button.
 
  Martin Grigorov
  Wicket Training and Consulting
  https://twitter.com/mtgrigorov
 
 
  On Tue, Sep 9, 2014 at 3:45 PM, Tobias Soloschenko 
  tobiassolosche...@googlemail.com wrote:
 
  And thats the question I was looking for - how do I get the current
  page id within the class that generates the url which is no component
  and the second question was how do I get the page to that id, because
  (Page)
  WebSession.get().getPageManager().getPage(i.get()) returns null for
  int i 0-10, event if I cleared the browsers cache / restarted the
 server.
 
  kind regards and big thanks for all the help!
 
  Tobias
 
  2014-09-09 14:28 GMT+02:00 Martin Grigorov mgrigo...@apache.org:
 
  Session#pageId is a counter that is used to give an id to the next
  created
  page.
  It is not the id of the currently used page!
 
  You will need to provide the pageId somehow to the class that
  generates
  the
  url.
 
  Martin Grigorov
  Wicket Training and Consulting
  https://twitter.com/mtgrigorov
 
 
  On Tue, Sep 9, 2014 at 3:13 PM, Tobias Soloschenko 
  tobiassolosche...@googlemail.com wrote:
 
  The method getPage() is not available at the place where I'm
  building
  the
  link - I'm not within a component and I try to get the page by
  content
  of
  the session. :-)
 
  I didn't modified the Session - the pageId is stored in
  org.apache.wicket.Session.pageId which is an AtomicInteger
 
 
  2014-09-09 14:06 GMT+02:00 Martin Grigorov mgrigo...@apache.org:
 
  Pass the pageId as a query string parameter.
 
  PageParameters params = new PageParameters(); params.set(pageId,
  getPage().getPageId()); theUrlToTheReference =
  requestCycle.urlFor(yourResRef, params);
 
  Then in the IResource (better extend AbstractResource) just read
  it
  from
  the request parameters.
 
  Storing the pageId in the session is not OK because the user may
  open
  two
  different pages in separate tabs/windows and this will break.
 
 
  Martin Grigorov
  Wicket Training and Consulting
  https://twitter.com/mtgrigorov
 
 
  On Tue, Sep 9, 2014 at 3:01 PM, Tobias Soloschenko 
  tobiassolosche...@googlemail.com wrote:
 
  Thanks again for the fast answer. My code now looks this way:
 
Field declaredField =
  WebSession.get().getClass().getSuperclass()
.getDeclaredField(pageId);
 
declaredField.setAccessible(true);
AtomicInteger i = (AtomicInteger)
  declaredField.get(WebSession.get());
Page page = (Page) WebSession.get().getPageManager()
.getPage(i.get());
 
AjaxRequestTarget newAjaxRequestTarget =
  ((WebApplication)
  Application.get())
.newAjaxRequestTarget(page);
 
RequestCycle.get().scheduleRequestHandlerAfterCurrent(
newAjaxRequestTarget);
 
  I dont know how to get the current pageId but from the Session.
  The
  page
  at
  this place is null. :-(
 
 
 
  2014-09-09 13:53 GMT+02:00 Martin Grigorov mgrigo...@apache.org:
 
  On Tue, Sep 9, 2014 at 2:05 PM, Tobias Soloschenko 
  tobiassolosche...@googlemail.com wrote

Re: Global Ajax Event Handler

2014-09-10 Thread Tobias Soloschenko
Oh NO

This completely solved my problem

Now all is working like expected...

Now I'm able to render a Javascript-Callback-Function with a custom
EL-Function within a JSP and if I use this Javascript-Function in a link
for example I can update component on the current page. Example:

wicket:jsp file=/TestPage.jsp /

In JSP:

a href=# onClick=${wicket:createAjaxCallback()}Update/a

In WebPage with setStatelassHint(false):

@Override
public void onEvent(IEvent? event) {
if (event.getPayload() instanceof GlobalAjaxEvent) {
AjaxRequestTarget ajaxRequestTarget =
((GlobalAjaxEvent)event.getPayload()).getAjaxRequestTarget();
label.setDefaultModelObject(updated panel);
ajaxRequestTarget.add(label);
}
 }

and in Application's init method:

GlobalAjaxResource.configure(this);

I will try out to make this call also available to forms or other html
elements within jsps and then I'm going to publish it on wicketstuff minis.
:-)

Thanks a lot for all the help and time you spend by solving this problem!

kind regards

Tobias



2014-09-10 12:16 GMT+02:00 Martin Grigorov mgrigo...@apache.org:

 Tobias sent me a quickstart app.

 TestPage is stateless and thus never stored in the storages.
 Just add setStatelessHint(false) to its constructor and the problem
 disappears.

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


 On Tue, Sep 9, 2014 at 10:10 PM, Tobias Soloschenko 
 tobiassolosche...@googlemail.com wrote:

  The usecase requires it :-) I send an example to you.
 
  I hope this will be possible because then you are also able to do ajax
  requests from embedded jsp files. :-D
 
  thanks anyway!
 
   Am 09.09.2014 um 16:29 schrieb Richter, Marvin 
  marvin.rich...@freenetdigital.com:
  
   That definitely sounds like a really odd use case or am I wrong?
  
   Do you really want to generate the URL outside from the Wicket context?
   I mean this is something which is heavily tied to wicket anyway so why
  not generating it inside it's context?
   And where do you need/use the final generated URL? I guess inside the
  Wicket context ...
  
   Maybe you should rethinking your use case, I bet the problem you're
  trying to solve can be solved much, much easier!
  
   Anyway .. wish you luck ;)
  
   -Original Message-
   From: Tobias Soloschenko [mailto:tobiassolosche...@googlemail.com]
   Sent: Tuesday, September 09, 2014 2:58 PM
   To: users@wicket.apache.org
   Subject: Re: Global Ajax Event Handler
  
   Thats the point. It is not used within a Component / Behavior - so I
  cant use getPage() ...
  
   Am 09.09.2014 um 14:50 schrieb Martin Grigorov mgrigo...@apache.org
 :
  
   The UrlGenerator class is used somewhere where the Page is available,
  no ?
   In SomeComponent/SomeBehavior:
  
   UrlGenerator generator = new UrlGenerator(); Url url =
   generator.generate(getPage().getPageId());
  
   Session.get().getPageManager().getPage(exisingAndNonExpiredPageId) is
   the way to get a reference to the page.
   Wicket uses this API internally every time you click a link or button.
  
   Martin Grigorov
   Wicket Training and Consulting
   https://twitter.com/mtgrigorov
  
  
   On Tue, Sep 9, 2014 at 3:45 PM, Tobias Soloschenko 
   tobiassolosche...@googlemail.com wrote:
  
   And thats the question I was looking for - how do I get the current
   page id within the class that generates the url which is no component
   and the second question was how do I get the page to that id, because
   (Page)
   WebSession.get().getPageManager().getPage(i.get()) returns null for
   int i 0-10, event if I cleared the browsers cache / restarted the
  server.
  
   kind regards and big thanks for all the help!
  
   Tobias
  
   2014-09-09 14:28 GMT+02:00 Martin Grigorov mgrigo...@apache.org:
  
   Session#pageId is a counter that is used to give an id to the next
   created
   page.
   It is not the id of the currently used page!
  
   You will need to provide the pageId somehow to the class that
   generates
   the
   url.
  
   Martin Grigorov
   Wicket Training and Consulting
   https://twitter.com/mtgrigorov
  
  
   On Tue, Sep 9, 2014 at 3:13 PM, Tobias Soloschenko 
   tobiassolosche...@googlemail.com wrote:
  
   The method getPage() is not available at the place where I'm
   building
   the
   link - I'm not within a component and I try to get the page by
   content
   of
   the session. :-)
  
   I didn't modified the Session - the pageId is stored in
   org.apache.wicket.Session.pageId which is an AtomicInteger
  
  
   2014-09-09 14:06 GMT+02:00 Martin Grigorov mgrigo...@apache.org:
  
   Pass the pageId as a query string parameter.
  
   PageParameters params = new PageParameters(); params.set(pageId,
   getPage().getPageId()); theUrlToTheReference =
   requestCycle.urlFor(yourResRef, params);
  
   Then in the IResource (better extend AbstractResource) just read
   it
   from
   the request parameters.
  
   Storing the pageId

Re: Global Ajax Event Handler

2014-09-09 Thread Martin Grigorov
What exactly you want to do ?

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


On Tue, Sep 9, 2014 at 11:58 AM, Tobias Soloschenko 
tobiassolosche...@googlemail.com wrote:

 Hi all,

 is there a way to register a global ajax event handler within Wicket? For
 normal there is the AbstractDefaultAjaxBehavior which is added to a
 component. And then the CallbackScript can be obtained and used within a
 OnDomReadyHeaderItem for example.

 Is there a way to do this on application level so that Im able to get the
 CallbackScript from the instantiated Application?

 kind regards

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




Re: Global Ajax Event Handler

2014-09-09 Thread Tom Götz
See https://cwiki.apache.org/confluence/display/WICKET/Wicket+Ajax, section 
Global Ajax call listeners“.

Cheers,
   -Tom


On 09.09.2014, at 10:58, Tobias Soloschenko tobiassolosche...@googlemail.com 
wrote:

 Hi all, 
 
 is there a way to register a global ajax event handler within Wicket? For 
 normal there is the AbstractDefaultAjaxBehavior which is added to a 
 component. And then the CallbackScript can be obtained and used within a 
 OnDomReadyHeaderItem for example.
 
 Is there a way to do this on application level so that Im able to get the 
 CallbackScript from the instantiated Application? 
 
 kind regards 
 
 Tobias
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 






Re: Global Ajax Event Handler

2014-09-09 Thread Tobias Soloschenko
I want to have the possibility to add a listener at application Level like in 
this pseudo code 

Server side
getGlobalAjaxBehaviors().add(myid,new GlobalAjaxBehavior(){

 public void respond(GlobalRequest request){
 // here the Event is received 
// request.getArguments();
 // request.replace(...)
}
}

Client side
Wicket.Ajax.get({id,somearguments});

This would allow me to send ajax request from any applications rendered at the 
Same page but which aren't able to access the wicket component structure. But 
within the event I would like to add and replace components based on the given 
args. Maybe application is Not the right place - Page would also be ok by 
adding the page class to the listener instead an id and the page class itself 
could implement an Interface for handling the event.

kind regards 

Tobias 

 Am 09.09.2014 um 11:06 schrieb Martin Grigorov mgrigo...@apache.org:
 
 What exactly you want to do ?
 
 Martin Grigorov
 Wicket Training and Consulting
 https://twitter.com/mtgrigorov
 
 
 On Tue, Sep 9, 2014 at 11:58 AM, Tobias Soloschenko 
 tobiassolosche...@googlemail.com wrote:
 
 Hi all,
 
 is there a way to register a global ajax event handler within Wicket? For
 normal there is the AbstractDefaultAjaxBehavior which is added to a
 component. And then the CallbackScript can be obtained and used within a
 OnDomReadyHeaderItem for example.
 
 Is there a way to do this on application level so that Im able to get the
 CallbackScript from the instantiated Application?
 
 kind regards
 
 Tobias
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 

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



Re: Global Ajax Event Handler

2014-09-09 Thread Tobias Soloschenko
Hi,

thanks for the answer, but this is only a client side event hook not for 
processing a request to the Server. I added a pseudo code to the question of 
martin who asked me what I exactly want to do.

Thanks anyway for the fast answer!

kind regards,

Tobias 

 Am 09.09.2014 um 11:06 schrieb Tom Götz t...@decoded.de:
 
 See https://cwiki.apache.org/confluence/display/WICKET/Wicket+Ajax, section 
 Global Ajax call listeners“.
 
 Cheers,
   -Tom
 
 
 On 09.09.2014, at 10:58, Tobias Soloschenko 
 tobiassolosche...@googlemail.com wrote:
 
 Hi all, 
 
 is there a way to register a global ajax event handler within Wicket? For 
 normal there is the AbstractDefaultAjaxBehavior which is added to a 
 component. And then the CallbackScript can be obtained and used within a 
 OnDomReadyHeaderItem for example.
 
 Is there a way to do this on application level so that Im able to get the 
 CallbackScript from the instantiated Application? 
 
 kind regards 
 
 Tobias
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 
 

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



Re: Global Ajax Event Handler

2014-09-09 Thread Martin Grigorov
I am still confused :-)
You used class names which are not available in Wicket 6.17.0 so I cannot
map them to any functionality that is possible with local behavior.

My guess is that you ask
about org.apache.wicket.ajax.AjaxRequestTarget.IListener#updateAjaxAttributes()
You can register custom listener like this:
https://github.com/apache/wicket/blob/master/wicket-core/src/test/java/org/apache/wicket/ajax/GlobalUpdateAjaxAttributesTest.java#L40

This way you have a global (server side, application-wide) way to
manipulate the AjaxRequestAttributes for *all* Ajax behaviors/components.

Does this solve the problem ?
If NO then please explain how you would do it the local way.


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


On Tue, Sep 9, 2014 at 12:26 PM, Tobias Soloschenko 
tobiassolosche...@googlemail.com wrote:

 I want to have the possibility to add a listener at application Level like
 in this pseudo code

 Server side
 getGlobalAjaxBehaviors().add(myid,new GlobalAjaxBehavior(){

  public void respond(GlobalRequest request){
  // here the Event is received
 // request.getArguments();
  // request.replace(...)
 }
 }

 Client side
 Wicket.Ajax.get({id,somearguments});

 This would allow me to send ajax request from any applications rendered at
 the Same page but which aren't able to access the wicket component
 structure. But within the event I would like to add and replace components
 based on the given args. Maybe application is Not the right place - Page
 would also be ok by adding the page class to the listener instead an id and
 the page class itself could implement an Interface for handling the event.

 kind regards

 Tobias

  Am 09.09.2014 um 11:06 schrieb Martin Grigorov mgrigo...@apache.org:
 
  What exactly you want to do ?
 
  Martin Grigorov
  Wicket Training and Consulting
  https://twitter.com/mtgrigorov
 
 
  On Tue, Sep 9, 2014 at 11:58 AM, Tobias Soloschenko 
  tobiassolosche...@googlemail.com wrote:
 
  Hi all,
 
  is there a way to register a global ajax event handler within Wicket?
 For
  normal there is the AbstractDefaultAjaxBehavior which is added to a
  component. And then the CallbackScript can be obtained and used within a
  OnDomReadyHeaderItem for example.
 
  Is there a way to do this on application level so that Im able to get
 the
  CallbackScript from the instantiated Application?
 
  kind regards
 
  Tobias
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 
 

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




RE: Global Ajax Event Handler

2014-09-09 Thread Richter, Marvin
What you are looking for is the Wicket Event mechanism.

This allows you to send a broadcast to a specified Component (e.g. the current 
page) and a payload (e.g. your custom event type which contains information).

In the Components which should react on the event you override the method 
onEvent, check if the event is of your type and if so, do with the event 
payload whatever you want.

Check out 
http://www.wicket-library.com/wicket-examples/events/wicket/bookmarkable/org.apache.wicket.examples.source.SourcesPage?1SourcesPage_class=org.apache.wicket.examples.events.DecoupledAjaxUpdatePage
 for a good example.

Best,
Marvin

-Original Message-
From: Tobias Soloschenko [mailto:tobiassolosche...@googlemail.com] 
Sent: Tuesday, September 09, 2014 11:31 AM
To: users@wicket.apache.org
Subject: Re: Global Ajax Event Handler

Hi,

thanks for the answer, but this is only a client side event hook not for 
processing a request to the Server. I added a pseudo code to the question of 
martin who asked me what I exactly want to do.

Thanks anyway for the fast answer!

kind regards,

Tobias 

 Am 09.09.2014 um 11:06 schrieb Tom Götz t...@decoded.de:
 
 See https://cwiki.apache.org/confluence/display/WICKET/Wicket+Ajax, section 
 Global Ajax call listeners“.
 
 Cheers,
   -Tom
 
 
 On 09.09.2014, at 10:58, Tobias Soloschenko 
 tobiassolosche...@googlemail.com wrote:
 
 Hi all, 
 
 is there a way to register a global ajax event handler within Wicket? For 
 normal there is the AbstractDefaultAjaxBehavior which is added to a 
 component. And then the CallbackScript can be obtained and used within a 
 OnDomReadyHeaderItem for example.
 
 Is there a way to do this on application level so that Im able to get the 
 CallbackScript from the instantiated Application? 
 
 kind regards 
 
 Tobias
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 
 

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



Re: Global Ajax Event Handler

2014-09-09 Thread Martin Grigorov
I've re-read the message and I think I got it.
What you really need is a mounted resource
(WebApplication#mountResource(someResourceReference))
To get a url to it use: theUrl = requestCycle.urlFor(sameResRef,
parametersWithPageId)
Wicket.Ajax.get({u: theUrl, ...})
In IResource#respond() you can create AjaxRequestTarget with:

Page page = session.getPageManager().get(parameters.get(pageId))
target = webApplication.newAjaxRequestTarget(page)
requestCycle.scheduleRequestHandlerAfterCurrent(target);
page.send(page, Broadcast.BREADTH, new SomeEvent(target))

in SomeComponent#onEvent() use someEvent.getTarget().add(this) to add the
component when SomeEvent is broadcasted

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


On Tue, Sep 9, 2014 at 12:40 PM, Richter, Marvin 
marvin.rich...@freenetdigital.com wrote:

 What you are looking for is the Wicket Event mechanism.

 This allows you to send a broadcast to a specified Component (e.g. the
 current page) and a payload (e.g. your custom event type which contains
 information).

 In the Components which should react on the event you override the method
 onEvent, check if the event is of your type and if so, do with the event
 payload whatever you want.

 Check out
 http://www.wicket-library.com/wicket-examples/events/wicket/bookmarkable/org.apache.wicket.examples.source.SourcesPage?1SourcesPage_class=org.apache.wicket.examples.events.DecoupledAjaxUpdatePage
 for a good example.

 Best,
 Marvin

 -Original Message-
 From: Tobias Soloschenko [mailto:tobiassolosche...@googlemail.com]
 Sent: Tuesday, September 09, 2014 11:31 AM
 To: users@wicket.apache.org
 Subject: Re: Global Ajax Event Handler

 Hi,

 thanks for the answer, but this is only a client side event hook not for
 processing a request to the Server. I added a pseudo code to the question
 of martin who asked me what I exactly want to do.

 Thanks anyway for the fast answer!

 kind regards,

 Tobias

  Am 09.09.2014 um 11:06 schrieb Tom Götz t...@decoded.de:
 
  See https://cwiki.apache.org/confluence/display/WICKET/Wicket+Ajax,
 section Global Ajax call listeners“.
 
  Cheers,
-Tom
 
 
  On 09.09.2014, at 10:58, Tobias Soloschenko 
 tobiassolosche...@googlemail.com wrote:
 
  Hi all,
 
  is there a way to register a global ajax event handler within Wicket?
 For normal there is the AbstractDefaultAjaxBehavior which is added to a
 component. And then the CallbackScript can be obtained and used within a
 OnDomReadyHeaderItem for example.
 
  Is there a way to do this on application level so that Im able to get
 the CallbackScript from the instantiated Application?
 
  kind regards
 
  Tobias
  -
  To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
  For additional commands, e-mail: users-h...@wicket.apache.org
 
 
 
 

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




Re: Global Ajax Event Handler

2014-09-09 Thread Tobias Soloschenko
I only wrote some pseudo code to show what I want to do. In simple words:

I want to write javascript code that invokes a method on the server side. The 
method on Server side is going to refresh components. Everything should work 
without Rendering the javascript code within a wicket page / component.

Kind regards

Tobias 

 Am 09.09.2014 um 11:37 schrieb Martin Grigorov mgrigo...@apache.org:
 
 I am still confused :-)
 You used class names which are not available in Wicket 6.17.0 so I cannot
 map them to any functionality that is possible with local behavior.
 
 My guess is that you ask
 about 
 org.apache.wicket.ajax.AjaxRequestTarget.IListener#updateAjaxAttributes()
 You can register custom listener like this:
 https://github.com/apache/wicket/blob/master/wicket-core/src/test/java/org/apache/wicket/ajax/GlobalUpdateAjaxAttributesTest.java#L40
 
 This way you have a global (server side, application-wide) way to
 manipulate the AjaxRequestAttributes for *all* Ajax behaviors/components.
 
 Does this solve the problem ?
 If NO then please explain how you would do it the local way.
 
 
 Martin Grigorov
 Wicket Training and Consulting
 https://twitter.com/mtgrigorov
 
 
 On Tue, Sep 9, 2014 at 12:26 PM, Tobias Soloschenko 
 tobiassolosche...@googlemail.com wrote:
 
 I want to have the possibility to add a listener at application Level like
 in this pseudo code
 
 Server side
 getGlobalAjaxBehaviors().add(myid,new GlobalAjaxBehavior(){
 
 public void respond(GlobalRequest request){
 // here the Event is received
 // request.getArguments();
 // request.replace(...)
 }
 }
 
 Client side
 Wicket.Ajax.get({id,somearguments});
 
 This would allow me to send ajax request from any applications rendered at
 the Same page but which aren't able to access the wicket component
 structure. But within the event I would like to add and replace components
 based on the given args. Maybe application is Not the right place - Page
 would also be ok by adding the page class to the listener instead an id and
 the page class itself could implement an Interface for handling the event.
 
 kind regards
 
 Tobias
 
 Am 09.09.2014 um 11:06 schrieb Martin Grigorov mgrigo...@apache.org:
 
 What exactly you want to do ?
 
 Martin Grigorov
 Wicket Training and Consulting
 https://twitter.com/mtgrigorov
 
 
 On Tue, Sep 9, 2014 at 11:58 AM, Tobias Soloschenko 
 tobiassolosche...@googlemail.com wrote:
 
 Hi all,
 
 is there a way to register a global ajax event handler within Wicket?
 For
 normal there is the AbstractDefaultAjaxBehavior which is added to a
 component. And then the CallbackScript can be obtained and used within a
 OnDomReadyHeaderItem for example.
 
 Is there a way to do this on application level so that Im able to get
 the
 CallbackScript from the instantiated Application?
 
 kind regards
 
 Tobias
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 

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



Re: Global Ajax Event Handler

2014-09-09 Thread Tobias Soloschenko
Hi,

the example shows up event bubbling which is not what I mean. 

Thanks anyway :-)

Kind regards 

Tobias 
 Am 09.09.2014 um 11:40 schrieb Richter, Marvin 
 marvin.rich...@freenetdigital.com:
 
 What you are looking for is the Wicket Event mechanism.
 
 This allows you to send a broadcast to a specified Component (e.g. the 
 current page) and a payload (e.g. your custom event type which contains 
 information).
 
 In the Components which should react on the event you override the method 
 onEvent, check if the event is of your type and if so, do with the event 
 payload whatever you want.
 
 Check out 
 http://www.wicket-library.com/wicket-examples/events/wicket/bookmarkable/org.apache.wicket.examples.source.SourcesPage?1SourcesPage_class=org.apache.wicket.examples.events.DecoupledAjaxUpdatePage
  for a good example.
 
 Best,
 Marvin
 
 -Original Message-
 From: Tobias Soloschenko [mailto:tobiassolosche...@googlemail.com] 
 Sent: Tuesday, September 09, 2014 11:31 AM
 To: users@wicket.apache.org
 Subject: Re: Global Ajax Event Handler
 
 Hi,
 
 thanks for the answer, but this is only a client side event hook not for 
 processing a request to the Server. I added a pseudo code to the question of 
 martin who asked me what I exactly want to do.
 
 Thanks anyway for the fast answer!
 
 kind regards,
 
 Tobias 
 
 Am 09.09.2014 um 11:06 schrieb Tom Götz t...@decoded.de:
 
 See https://cwiki.apache.org/confluence/display/WICKET/Wicket+Ajax, section 
 Global Ajax call listeners“.
 
 Cheers,
  -Tom
 
 
 On 09.09.2014, at 10:58, Tobias Soloschenko 
 tobiassolosche...@googlemail.com wrote:
 
 Hi all, 
 
 is there a way to register a global ajax event handler within Wicket? For 
 normal there is the AbstractDefaultAjaxBehavior which is added to a 
 component. And then the CallbackScript can be obtained and used within a 
 OnDomReadyHeaderItem for example.
 
 Is there a way to do this on application level so that Im able to get the 
 CallbackScript from the instantiated Application? 
 
 kind regards 
 
 Tobias
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 ТÐÐ¥FòVç7V'67–RÂRÖÖ–âW6W'2×Vç7V'67–Tv–6¶WBæ6†Ræ÷pФf÷FF—F–öæÂ6öÖÖæG2ÂRÖÖ–âW6W'2Ö†VÇv–6¶WBæ6†Ræ÷pÐ
  

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



Re: Global Ajax Event Handler

2014-09-09 Thread Tobias Soloschenko
Thats it!!! Thanks!

Kind regards

Tobias 

Von meinem iPhone gesendet

 Am 09.09.2014 um 11:51 schrieb Martin Grigorov mgrigo...@apache.org:
 
 I've re-read the message and I think I got it.
 What you really need is a mounted resource
 (WebApplication#mountResource(someResourceReference))
 To get a url to it use: theUrl = requestCycle.urlFor(sameResRef,
 parametersWithPageId)
 Wicket.Ajax.get({u: theUrl, ...})
 In IResource#respond() you can create AjaxRequestTarget with:
 
 Page page = session.getPageManager().get(parameters.get(pageId))
 target = webApplication.newAjaxRequestTarget(page)
 requestCycle.scheduleRequestHandlerAfterCurrent(target);
 page.send(page, Broadcast.BREADTH, new SomeEvent(target))
 
 in SomeComponent#onEvent() use someEvent.getTarget().add(this) to add the
 component when SomeEvent is broadcasted
 
 Martin Grigorov
 Wicket Training and Consulting
 https://twitter.com/mtgrigorov
 
 
 On Tue, Sep 9, 2014 at 12:40 PM, Richter, Marvin 
 marvin.rich...@freenetdigital.com wrote:
 
 What you are looking for is the Wicket Event mechanism.
 
 This allows you to send a broadcast to a specified Component (e.g. the
 current page) and a payload (e.g. your custom event type which contains
 information).
 
 In the Components which should react on the event you override the method
 onEvent, check if the event is of your type and if so, do with the event
 payload whatever you want.
 
 Check out
 http://www.wicket-library.com/wicket-examples/events/wicket/bookmarkable/org.apache.wicket.examples.source.SourcesPage?1SourcesPage_class=org.apache.wicket.examples.events.DecoupledAjaxUpdatePage
 for a good example.
 
 Best,
 Marvin
 
 -Original Message-
 From: Tobias Soloschenko [mailto:tobiassolosche...@googlemail.com]
 Sent: Tuesday, September 09, 2014 11:31 AM
 To: users@wicket.apache.org
 Subject: Re: Global Ajax Event Handler
 
 Hi,
 
 thanks for the answer, but this is only a client side event hook not for
 processing a request to the Server. I added a pseudo code to the question
 of martin who asked me what I exactly want to do.
 
 Thanks anyway for the fast answer!
 
 kind regards,
 
 Tobias
 
 Am 09.09.2014 um 11:06 schrieb Tom Götz t...@decoded.de:
 
 See https://cwiki.apache.org/confluence/display/WICKET/Wicket+Ajax,
 section Global Ajax call listeners“.
 
 Cheers,
  -Tom
 
 
 On 09.09.2014, at 10:58, Tobias Soloschenko 
 tobiassolosche...@googlemail.com wrote:
 
 Hi all,
 
 is there a way to register a global ajax event handler within Wicket?
 For normal there is the AbstractDefaultAjaxBehavior which is added to a
 component. And then the CallbackScript can be obtained and used within a
 OnDomReadyHeaderItem for example.
 
 Is there a way to do this on application level so that Im able to get
 the CallbackScript from the instantiated Application?
 
 kind regards
 
 Tobias
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 

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



Re: Global Ajax Event Handler

2014-09-09 Thread Martin Grigorov
On Tue, Sep 9, 2014 at 2:05 PM, Tobias Soloschenko 
tobiassolosche...@googlemail.com wrote:

 Hi again,

 I tried out that code you mentioned here.
 WebSession.get().getPageManager().getPage(int i) returns IManageablePage
 which is not applicable as argument for newAjaxRequestTarget.


cast it
it is known that in your environment you don't use any custom
IManageablePage/IRequestablePage impls (see IPageFactory)



 The second thing is how do I get the instance of a page by class with the
 last page id not from within a component (this would be simple getPage())?


I didn't get this
Please re-phrase



 2014-09-09 11:51 GMT+02:00 Martin Grigorov mgrigo...@apache.org:

  I've re-read the message and I think I got it.
  What you really need is a mounted resource
  (WebApplication#mountResource(someResourceReference))
  To get a url to it use: theUrl = requestCycle.urlFor(sameResRef,
  parametersWithPageId)
  Wicket.Ajax.get({u: theUrl, ...})
  In IResource#respond() you can create AjaxRequestTarget with:
 
  Page page = session.getPageManager().get(parameters.get(pageId))
  target = webApplication.newAjaxRequestTarget(page)
  requestCycle.scheduleRequestHandlerAfterCurrent(target);
  page.send(page, Broadcast.BREADTH, new SomeEvent(target))
 
  in SomeComponent#onEvent() use someEvent.getTarget().add(this) to add the
  component when SomeEvent is broadcasted
 
  Martin Grigorov
  Wicket Training and Consulting
  https://twitter.com/mtgrigorov
 
 
  On Tue, Sep 9, 2014 at 12:40 PM, Richter, Marvin 
  marvin.rich...@freenetdigital.com wrote:
 
   What you are looking for is the Wicket Event mechanism.
  
   This allows you to send a broadcast to a specified Component (e.g. the
   current page) and a payload (e.g. your custom event type which contains
   information).
  
   In the Components which should react on the event you override the
 method
   onEvent, check if the event is of your type and if so, do with the
 event
   payload whatever you want.
  
   Check out
  
 
 http://www.wicket-library.com/wicket-examples/events/wicket/bookmarkable/org.apache.wicket.examples.source.SourcesPage?1SourcesPage_class=org.apache.wicket.examples.events.DecoupledAjaxUpdatePage
   for a good example.
  
   Best,
   Marvin
  
   -Original Message-
   From: Tobias Soloschenko [mailto:tobiassolosche...@googlemail.com]
   Sent: Tuesday, September 09, 2014 11:31 AM
   To: users@wicket.apache.org
   Subject: Re: Global Ajax Event Handler
  
   Hi,
  
   thanks for the answer, but this is only a client side event hook not
 for
   processing a request to the Server. I added a pseudo code to the
 question
   of martin who asked me what I exactly want to do.
  
   Thanks anyway for the fast answer!
  
   kind regards,
  
   Tobias
  
Am 09.09.2014 um 11:06 schrieb Tom Götz t...@decoded.de:
   
See https://cwiki.apache.org/confluence/display/WICKET/Wicket+Ajax,
   section Global Ajax call listeners“.
   
Cheers,
  -Tom
   
   
On 09.09.2014, at 10:58, Tobias Soloschenko 
   tobiassolosche...@googlemail.com wrote:
   
Hi all,
   
is there a way to register a global ajax event handler within
 Wicket?
   For normal there is the AbstractDefaultAjaxBehavior which is added to a
   component. And then the CallbackScript can be obtained and used within
 a
   OnDomReadyHeaderItem for example.
   
Is there a way to do this on application level so that Im able to
 get
   the CallbackScript from the instantiated Application?
   
kind regards
   
Tobias
   
 -
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org
   
   
   
   
  
   -
   To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
   For additional commands, e-mail: users-h...@wicket.apache.org
  
  
 



Re: Global Ajax Event Handler

2014-09-09 Thread Tobias Soloschenko
Thanks again for the fast answer. My code now looks this way:

Field declaredField =
WebSession.get().getClass().getSuperclass()
.getDeclaredField(pageId);

declaredField.setAccessible(true);
AtomicInteger i = (AtomicInteger)
declaredField.get(WebSession.get());
Page page = (Page) WebSession.get().getPageManager()
.getPage(i.get());

AjaxRequestTarget newAjaxRequestTarget = ((WebApplication)
Application.get())
.newAjaxRequestTarget(page);

RequestCycle.get().scheduleRequestHandlerAfterCurrent(
newAjaxRequestTarget);

I dont know how to get the current pageId but from the Session. The page at
this place is null. :-(



2014-09-09 13:53 GMT+02:00 Martin Grigorov mgrigo...@apache.org:

 On Tue, Sep 9, 2014 at 2:05 PM, Tobias Soloschenko 
 tobiassolosche...@googlemail.com wrote:

  Hi again,
 
  I tried out that code you mentioned here.
  WebSession.get().getPageManager().getPage(int i) returns IManageablePage
  which is not applicable as argument for newAjaxRequestTarget.
 

 cast it
 it is known that in your environment you don't use any custom
 IManageablePage/IRequestablePage impls (see IPageFactory)


 
  The second thing is how do I get the instance of a page by class with the
  last page id not from within a component (this would be simple
 getPage())?
 

 I didn't get this
 Please re-phrase


 
  2014-09-09 11:51 GMT+02:00 Martin Grigorov mgrigo...@apache.org:
 
   I've re-read the message and I think I got it.
   What you really need is a mounted resource
   (WebApplication#mountResource(someResourceReference))
   To get a url to it use: theUrl = requestCycle.urlFor(sameResRef,
   parametersWithPageId)
   Wicket.Ajax.get({u: theUrl, ...})
   In IResource#respond() you can create AjaxRequestTarget with:
  
   Page page = session.getPageManager().get(parameters.get(pageId))
   target = webApplication.newAjaxRequestTarget(page)
   requestCycle.scheduleRequestHandlerAfterCurrent(target);
   page.send(page, Broadcast.BREADTH, new SomeEvent(target))
  
   in SomeComponent#onEvent() use someEvent.getTarget().add(this) to add
 the
   component when SomeEvent is broadcasted
  
   Martin Grigorov
   Wicket Training and Consulting
   https://twitter.com/mtgrigorov
  
  
   On Tue, Sep 9, 2014 at 12:40 PM, Richter, Marvin 
   marvin.rich...@freenetdigital.com wrote:
  
What you are looking for is the Wicket Event mechanism.
   
This allows you to send a broadcast to a specified Component (e.g.
 the
current page) and a payload (e.g. your custom event type which
 contains
information).
   
In the Components which should react on the event you override the
  method
onEvent, check if the event is of your type and if so, do with the
  event
payload whatever you want.
   
Check out
   
  
 
 http://www.wicket-library.com/wicket-examples/events/wicket/bookmarkable/org.apache.wicket.examples.source.SourcesPage?1SourcesPage_class=org.apache.wicket.examples.events.DecoupledAjaxUpdatePage
for a good example.
   
Best,
Marvin
   
-Original Message-
From: Tobias Soloschenko [mailto:tobiassolosche...@googlemail.com]
Sent: Tuesday, September 09, 2014 11:31 AM
To: users@wicket.apache.org
Subject: Re: Global Ajax Event Handler
   
Hi,
   
thanks for the answer, but this is only a client side event hook not
  for
processing a request to the Server. I added a pseudo code to the
  question
of martin who asked me what I exactly want to do.
   
Thanks anyway for the fast answer!
   
kind regards,
   
Tobias
   
 Am 09.09.2014 um 11:06 schrieb Tom Götz t...@decoded.de:

 See https://cwiki.apache.org/confluence/display/WICKET/Wicket+Ajax
 ,
section Global Ajax call listeners“.

 Cheers,
   -Tom


 On 09.09.2014, at 10:58, Tobias Soloschenko 
tobiassolosche...@googlemail.com wrote:

 Hi all,

 is there a way to register a global ajax event handler within
  Wicket?
For normal there is the AbstractDefaultAjaxBehavior which is added
 to a
component. And then the CallbackScript can be obtained and used
 within
  a
OnDomReadyHeaderItem for example.

 Is there a way to do this on application level so that Im able to
  get
the CallbackScript from the instantiated Application?

 kind regards

 Tobias

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




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



Re: Global Ajax Event Handler

2014-09-09 Thread Martin Grigorov
Pass the pageId as a query string parameter.

PageParameters params = new PageParameters();
params.set(pageId, getPage().getPageId());
theUrlToTheReference = requestCycle.urlFor(yourResRef, params);

Then in the IResource (better extend AbstractResource) just read it from
the request parameters.

Storing the pageId in the session is not OK because the user may open two
different pages in separate tabs/windows and this will break.


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


On Tue, Sep 9, 2014 at 3:01 PM, Tobias Soloschenko 
tobiassolosche...@googlemail.com wrote:

 Thanks again for the fast answer. My code now looks this way:

 Field declaredField =
 WebSession.get().getClass().getSuperclass()
 .getDeclaredField(pageId);

 declaredField.setAccessible(true);
 AtomicInteger i = (AtomicInteger)
 declaredField.get(WebSession.get());
 Page page = (Page) WebSession.get().getPageManager()
 .getPage(i.get());

 AjaxRequestTarget newAjaxRequestTarget = ((WebApplication)
 Application.get())
 .newAjaxRequestTarget(page);

 RequestCycle.get().scheduleRequestHandlerAfterCurrent(
 newAjaxRequestTarget);

 I dont know how to get the current pageId but from the Session. The page at
 this place is null. :-(



 2014-09-09 13:53 GMT+02:00 Martin Grigorov mgrigo...@apache.org:

  On Tue, Sep 9, 2014 at 2:05 PM, Tobias Soloschenko 
  tobiassolosche...@googlemail.com wrote:
 
   Hi again,
  
   I tried out that code you mentioned here.
   WebSession.get().getPageManager().getPage(int i) returns
 IManageablePage
   which is not applicable as argument for newAjaxRequestTarget.
  
 
  cast it
  it is known that in your environment you don't use any custom
  IManageablePage/IRequestablePage impls (see IPageFactory)
 
 
  
   The second thing is how do I get the instance of a page by class with
 the
   last page id not from within a component (this would be simple
  getPage())?
  
 
  I didn't get this
  Please re-phrase
 
 
  
   2014-09-09 11:51 GMT+02:00 Martin Grigorov mgrigo...@apache.org:
  
I've re-read the message and I think I got it.
What you really need is a mounted resource
(WebApplication#mountResource(someResourceReference))
To get a url to it use: theUrl = requestCycle.urlFor(sameResRef,
parametersWithPageId)
Wicket.Ajax.get({u: theUrl, ...})
In IResource#respond() you can create AjaxRequestTarget with:
   
Page page = session.getPageManager().get(parameters.get(pageId))
target = webApplication.newAjaxRequestTarget(page)
requestCycle.scheduleRequestHandlerAfterCurrent(target);
page.send(page, Broadcast.BREADTH, new SomeEvent(target))
   
in SomeComponent#onEvent() use someEvent.getTarget().add(this) to add
  the
component when SomeEvent is broadcasted
   
Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov
   
   
On Tue, Sep 9, 2014 at 12:40 PM, Richter, Marvin 
marvin.rich...@freenetdigital.com wrote:
   
 What you are looking for is the Wicket Event mechanism.

 This allows you to send a broadcast to a specified Component (e.g.
  the
 current page) and a payload (e.g. your custom event type which
  contains
 information).

 In the Components which should react on the event you override the
   method
 onEvent, check if the event is of your type and if so, do with the
   event
 payload whatever you want.

 Check out

   
  
 
 http://www.wicket-library.com/wicket-examples/events/wicket/bookmarkable/org.apache.wicket.examples.source.SourcesPage?1SourcesPage_class=org.apache.wicket.examples.events.DecoupledAjaxUpdatePage
 for a good example.

 Best,
 Marvin

 -Original Message-
 From: Tobias Soloschenko [mailto:tobiassolosche...@googlemail.com]
 Sent: Tuesday, September 09, 2014 11:31 AM
 To: users@wicket.apache.org
 Subject: Re: Global Ajax Event Handler

 Hi,

 thanks for the answer, but this is only a client side event hook
 not
   for
 processing a request to the Server. I added a pseudo code to the
   question
 of martin who asked me what I exactly want to do.

 Thanks anyway for the fast answer!

 kind regards,

 Tobias

  Am 09.09.2014 um 11:06 schrieb Tom Götz t...@decoded.de:
 
  See
 https://cwiki.apache.org/confluence/display/WICKET/Wicket+Ajax
  ,
 section Global Ajax call listeners“.
 
  Cheers,
-Tom
 
 
  On 09.09.2014, at 10:58, Tobias Soloschenko 
 tobiassolosche...@googlemail.com wrote:
 
  Hi all,
 
  is there a way to register a global ajax event handler within
   Wicket?
 For normal there is the AbstractDefaultAjaxBehavior which is added
  to a
 component. And then the CallbackScript can be obtained and used

Re: Global Ajax Event Handler

2014-09-09 Thread Tobias Soloschenko
The method getPage() is not available at the place where I'm building the
link - I'm not within a component and I try to get the page by content of
the session. :-)

I didn't modified the Session - the pageId is stored in
org.apache.wicket.Session.pageId which is an AtomicInteger


2014-09-09 14:06 GMT+02:00 Martin Grigorov mgrigo...@apache.org:

 Pass the pageId as a query string parameter.

 PageParameters params = new PageParameters();
 params.set(pageId, getPage().getPageId());
 theUrlToTheReference = requestCycle.urlFor(yourResRef, params);

 Then in the IResource (better extend AbstractResource) just read it from
 the request parameters.

 Storing the pageId in the session is not OK because the user may open two
 different pages in separate tabs/windows and this will break.


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


 On Tue, Sep 9, 2014 at 3:01 PM, Tobias Soloschenko 
 tobiassolosche...@googlemail.com wrote:

  Thanks again for the fast answer. My code now looks this way:
 
  Field declaredField =
  WebSession.get().getClass().getSuperclass()
  .getDeclaredField(pageId);
 
  declaredField.setAccessible(true);
  AtomicInteger i = (AtomicInteger)
  declaredField.get(WebSession.get());
  Page page = (Page) WebSession.get().getPageManager()
  .getPage(i.get());
 
  AjaxRequestTarget newAjaxRequestTarget = ((WebApplication)
  Application.get())
  .newAjaxRequestTarget(page);
 
  RequestCycle.get().scheduleRequestHandlerAfterCurrent(
  newAjaxRequestTarget);
 
  I dont know how to get the current pageId but from the Session. The page
 at
  this place is null. :-(
 
 
 
  2014-09-09 13:53 GMT+02:00 Martin Grigorov mgrigo...@apache.org:
 
   On Tue, Sep 9, 2014 at 2:05 PM, Tobias Soloschenko 
   tobiassolosche...@googlemail.com wrote:
  
Hi again,
   
I tried out that code you mentioned here.
WebSession.get().getPageManager().getPage(int i) returns
  IManageablePage
which is not applicable as argument for newAjaxRequestTarget.
   
  
   cast it
   it is known that in your environment you don't use any custom
   IManageablePage/IRequestablePage impls (see IPageFactory)
  
  
   
The second thing is how do I get the instance of a page by class with
  the
last page id not from within a component (this would be simple
   getPage())?
   
  
   I didn't get this
   Please re-phrase
  
  
   
2014-09-09 11:51 GMT+02:00 Martin Grigorov mgrigo...@apache.org:
   
 I've re-read the message and I think I got it.
 What you really need is a mounted resource
 (WebApplication#mountResource(someResourceReference))
 To get a url to it use: theUrl = requestCycle.urlFor(sameResRef,
 parametersWithPageId)
 Wicket.Ajax.get({u: theUrl, ...})
 In IResource#respond() you can create AjaxRequestTarget with:

 Page page = session.getPageManager().get(parameters.get(pageId))
 target = webApplication.newAjaxRequestTarget(page)
 requestCycle.scheduleRequestHandlerAfterCurrent(target);
 page.send(page, Broadcast.BREADTH, new SomeEvent(target))

 in SomeComponent#onEvent() use someEvent.getTarget().add(this) to
 add
   the
 component when SomeEvent is broadcasted

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


 On Tue, Sep 9, 2014 at 12:40 PM, Richter, Marvin 
 marvin.rich...@freenetdigital.com wrote:

  What you are looking for is the Wicket Event mechanism.
 
  This allows you to send a broadcast to a specified Component
 (e.g.
   the
  current page) and a payload (e.g. your custom event type which
   contains
  information).
 
  In the Components which should react on the event you override
 the
method
  onEvent, check if the event is of your type and if so, do with
 the
event
  payload whatever you want.
 
  Check out
 

   
  
 
 http://www.wicket-library.com/wicket-examples/events/wicket/bookmarkable/org.apache.wicket.examples.source.SourcesPage?1SourcesPage_class=org.apache.wicket.examples.events.DecoupledAjaxUpdatePage
  for a good example.
 
  Best,
  Marvin
 
  -Original Message-
  From: Tobias Soloschenko [mailto:
 tobiassolosche...@googlemail.com]
  Sent: Tuesday, September 09, 2014 11:31 AM
  To: users@wicket.apache.org
  Subject: Re: Global Ajax Event Handler
 
  Hi,
 
  thanks for the answer, but this is only a client side event hook
  not
for
  processing a request to the Server. I added a pseudo code to the
question
  of martin who asked me what I exactly want to do.
 
  Thanks anyway for the fast answer!
 
  kind regards,
 
  Tobias
 
   Am 09.09.2014 um 11:06 schrieb Tom Götz t...@decoded.de:
  
   See
  https

Re: Global Ajax Event Handler

2014-09-09 Thread Martin Grigorov
, 2014 11:31 AM
   To: users@wicket.apache.org
   Subject: Re: Global Ajax Event Handler
  
   Hi,
  
   thanks for the answer, but this is only a client side event
 hook
   not
 for
   processing a request to the Server. I added a pseudo code to
 the
 question
   of martin who asked me what I exactly want to do.
  
   Thanks anyway for the fast answer!
  
   kind regards,
  
   Tobias
  
Am 09.09.2014 um 11:06 schrieb Tom Götz t...@decoded.de:
   
See
   https://cwiki.apache.org/confluence/display/WICKET/Wicket+Ajax
,
   section Global Ajax call listeners“.
   
Cheers,
  -Tom
   
   
On 09.09.2014, at 10:58, Tobias Soloschenko 
   tobiassolosche...@googlemail.com wrote:
   
Hi all,
   
is there a way to register a global ajax event handler
 within
 Wicket?
   For normal there is the AbstractDefaultAjaxBehavior which is
  added
to a
   component. And then the CallbackScript can be obtained and used
within
 a
   OnDomReadyHeaderItem for example.
   
Is there a way to do this on application level so that Im
 able
   to
 get
   the CallbackScript from the instantiated Application?
   
kind regards
   
Tobias
   

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

   
  
 



Re: Global Ajax Event Handler

2014-09-09 Thread Tobias Soloschenko
 on the event you
 override
   the
  method
onEvent, check if the event is of your type and if so, do
 with
   the
  event
payload whatever you want.
   
Check out
   
  
 

   
  
 
 http://www.wicket-library.com/wicket-examples/events/wicket/bookmarkable/org.apache.wicket.examples.source.SourcesPage?1SourcesPage_class=org.apache.wicket.examples.events.DecoupledAjaxUpdatePage
for a good example.
   
Best,
Marvin
   
-Original Message-
From: Tobias Soloschenko [mailto:
   tobiassolosche...@googlemail.com]
Sent: Tuesday, September 09, 2014 11:31 AM
To: users@wicket.apache.org
Subject: Re: Global Ajax Event Handler
   
Hi,
   
thanks for the answer, but this is only a client side event
  hook
not
  for
processing a request to the Server. I added a pseudo code to
  the
  question
of martin who asked me what I exactly want to do.
   
Thanks anyway for the fast answer!
   
kind regards,
   
Tobias
   
 Am 09.09.2014 um 11:06 schrieb Tom Götz t...@decoded.de:

 See
https://cwiki.apache.org/confluence/display/WICKET/Wicket+Ajax
 ,
section Global Ajax call listeners“.

 Cheers,
   -Tom


 On 09.09.2014, at 10:58, Tobias Soloschenko 
tobiassolosche...@googlemail.com wrote:

 Hi all,

 is there a way to register a global ajax event handler
  within
  Wicket?
For normal there is the AbstractDefaultAjaxBehavior which is
   added
 to a
component. And then the CallbackScript can be obtained and
 used
 within
  a
OnDomReadyHeaderItem for example.

 Is there a way to do this on application level so that Im
  able
to
  get
the CallbackScript from the instantiated Application?

 kind regards

 Tobias

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




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

   
  
 



Re: Global Ajax Event Handler

2014-09-09 Thread Martin Grigorov
))
   
in SomeComponent#onEvent() use
 someEvent.getTarget().add(this)
  to
add
  the
component when SomeEvent is broadcasted
   
Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov
   
   
On Tue, Sep 9, 2014 at 12:40 PM, Richter, Marvin 
marvin.rich...@freenetdigital.com wrote:
   
 What you are looking for is the Wicket Event mechanism.

 This allows you to send a broadcast to a specified
 Component
(e.g.
  the
 current page) and a payload (e.g. your custom event type
  which
  contains
 information).

 In the Components which should react on the event you
  override
the
   method
 onEvent, check if the event is of your type and if so, do
  with
the
   event
 payload whatever you want.

 Check out

   
  
 

   
  
 
 http://www.wicket-library.com/wicket-examples/events/wicket/bookmarkable/org.apache.wicket.examples.source.SourcesPage?1SourcesPage_class=org.apache.wicket.examples.events.DecoupledAjaxUpdatePage
 for a good example.

 Best,
 Marvin

 -Original Message-
 From: Tobias Soloschenko [mailto:
tobiassolosche...@googlemail.com]
 Sent: Tuesday, September 09, 2014 11:31 AM
 To: users@wicket.apache.org
 Subject: Re: Global Ajax Event Handler

 Hi,

 thanks for the answer, but this is only a client side event
   hook
 not
   for
 processing a request to the Server. I added a pseudo code
 to
   the
   question
 of martin who asked me what I exactly want to do.

 Thanks anyway for the fast answer!

 kind regards,

 Tobias

  Am 09.09.2014 um 11:06 schrieb Tom Götz t...@decoded.de
 :
 
  See
 https://cwiki.apache.org/confluence/display/WICKET/Wicket+Ajax
  ,
 section Global Ajax call listeners“.
 
  Cheers,
-Tom
 
 
  On 09.09.2014, at 10:58, Tobias Soloschenko 
 tobiassolosche...@googlemail.com wrote:
 
  Hi all,
 
  is there a way to register a global ajax event handler
   within
   Wicket?
 For normal there is the AbstractDefaultAjaxBehavior which
 is
added
  to a
 component. And then the CallbackScript can be obtained and
  used
  within
   a
 OnDomReadyHeaderItem for example.
 
  Is there a way to do this on application level so that
 Im
   able
 to
   get
 the CallbackScript from the instantiated Application?
 
  kind regards
 
  Tobias
 
  
   -
  To unsubscribe, e-mail:
  users-unsubscr...@wicket.apache.org
  For additional commands, e-mail:
   users-h...@wicket.apache.org
 
 
 
 



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


   
  
 

   
  
 



Re: Global Ajax Event Handler

2014-09-09 Thread Tobias Soloschenko
, Richter, Marvin 
 marvin.rich...@freenetdigital.com wrote:
 
 What you are looking for is the Wicket Event mechanism.
 
 This allows you to send a broadcast to a specified
 Component
 (e.g.
 the
 current page) and a payload (e.g. your custom event type
 which
 contains
 information).
 
 In the Components which should react on the event you
 override
 the
 method
 onEvent, check if the event is of your type and if so, do
 with
 the
 event
 payload whatever you want.
 
 Check out
 http://www.wicket-library.com/wicket-examples/events/wicket/bookmarkable/org.apache.wicket.examples.source.SourcesPage?1SourcesPage_class=org.apache.wicket.examples.events.DecoupledAjaxUpdatePage
 for a good example.
 
 Best,
 Marvin
 
 -Original Message-
 From: Tobias Soloschenko [mailto:
 tobiassolosche...@googlemail.com]
 Sent: Tuesday, September 09, 2014 11:31 AM
 To: users@wicket.apache.org
 Subject: Re: Global Ajax Event Handler
 
 Hi,
 
 thanks for the answer, but this is only a client side event
 hook
 not
 for
 processing a request to the Server. I added a pseudo code
 to
 the
 question
 of martin who asked me what I exactly want to do.
 
 Thanks anyway for the fast answer!
 
 kind regards,
 
 Tobias
 
 Am 09.09.2014 um 11:06 schrieb Tom Götz t...@decoded.de
 :
 
 See
 https://cwiki.apache.org/confluence/display/WICKET/Wicket+Ajax
 ,
 section Global Ajax call listeners“.
 
 Cheers,
  -Tom
 
 
 On 09.09.2014, at 10:58, Tobias Soloschenko 
 tobiassolosche...@googlemail.com wrote:
 
 Hi all,
 
 is there a way to register a global ajax event handler
 within
 Wicket?
 For normal there is the AbstractDefaultAjaxBehavior which
 is
 added
 to a
 component. And then the CallbackScript can be obtained and
 used
 within
 a
 OnDomReadyHeaderItem for example.
 
 Is there a way to do this on application level so that
 Im
 able
 to
 get
 the CallbackScript from the instantiated Application?
 
 kind regards
 
 Tobias
 -
 To unsubscribe, e-mail:
 users-unsubscr...@wicket.apache.org
 For additional commands, e-mail:
 users-h...@wicket.apache.org
 -
 To unsubscribe, e-mail:
 users-unsubscr...@wicket.apache.org
 For additional commands, e-mail:
 users-h...@wicket.apache.org
 

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



Re: Global Ajax Event Handler

2014-09-09 Thread Tobias Soloschenko
/mtgrigorov
 
 
 On Tue, Sep 9, 2014 at 12:40 PM, Richter, Marvin 
 marvin.rich...@freenetdigital.com wrote:
 
 What you are looking for is the Wicket Event mechanism.
 
 This allows you to send a broadcast to a specified
 Component
 (e.g.
 the
 current page) and a payload (e.g. your custom event type
 which
 contains
 information).
 
 In the Components which should react on the event you
 override
 the
 method
 onEvent, check if the event is of your type and if so, do
 with
 the
 event
 payload whatever you want.
 
 Check out
 http://www.wicket-library.com/wicket-examples/events/wicket/bookmarkable/org.apache.wicket.examples.source.SourcesPage?1SourcesPage_class=org.apache.wicket.examples.events.DecoupledAjaxUpdatePage
 for a good example.
 
 Best,
 Marvin
 
 -Original Message-
 From: Tobias Soloschenko [mailto:
 tobiassolosche...@googlemail.com]
 Sent: Tuesday, September 09, 2014 11:31 AM
 To: users@wicket.apache.org
 Subject: Re: Global Ajax Event Handler
 
 Hi,
 
 thanks for the answer, but this is only a client side event
 hook
 not
 for
 processing a request to the Server. I added a pseudo code
 to
 the
 question
 of martin who asked me what I exactly want to do.
 
 Thanks anyway for the fast answer!
 
 kind regards,
 
 Tobias
 
 Am 09.09.2014 um 11:06 schrieb Tom Götz t...@decoded.de
 :
 
 See
 https://cwiki.apache.org/confluence/display/WICKET/Wicket+Ajax
 ,
 section Global Ajax call listeners“.
 
 Cheers,
  -Tom
 
 
 On 09.09.2014, at 10:58, Tobias Soloschenko 
 tobiassolosche...@googlemail.com wrote:
 
 Hi all,
 
 is there a way to register a global ajax event handler
 within
 Wicket?
 For normal there is the AbstractDefaultAjaxBehavior which
 is
 added
 to a
 component. And then the CallbackScript can be obtained and
 used
 within
 a
 OnDomReadyHeaderItem for example.
 
 Is there a way to do this on application level so that
 Im
 able
 to
 get
 the CallbackScript from the instantiated Application?
 
 kind regards
 
 Tobias
 -
 To unsubscribe, e-mail:
 users-unsubscr...@wicket.apache.org
 For additional commands, e-mail:
 users-h...@wicket.apache.org
 -
 To unsubscribe, e-mail:
 users-unsubscr...@wicket.apache.org
 For additional commands, e-mail:
 users-h...@wicket.apache.org
 

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



Re: Global Ajax Event Handler

2014-09-09 Thread Martin Grigorov
)
  requestCycle.scheduleRequestHandlerAfterCurrent(target);
  page.send(page, Broadcast.BREADTH, new SomeEvent(target))
 
  in SomeComponent#onEvent() use
  someEvent.getTarget().add(this)
  to
  add
  the
  component when SomeEvent is broadcasted
 
  Martin Grigorov
  Wicket Training and Consulting
  https://twitter.com/mtgrigorov
 
 
  On Tue, Sep 9, 2014 at 12:40 PM, Richter, Marvin 
  marvin.rich...@freenetdigital.com wrote:
 
  What you are looking for is the Wicket Event mechanism.
 
  This allows you to send a broadcast to a specified
  Component
  (e.g.
  the
  current page) and a payload (e.g. your custom event type
  which
  contains
  information).
 
  In the Components which should react on the event you
  override
  the
  method
  onEvent, check if the event is of your type and if so, do
  with
  the
  event
  payload whatever you want.
 
  Check out
 
 http://www.wicket-library.com/wicket-examples/events/wicket/bookmarkable/org.apache.wicket.examples.source.SourcesPage?1SourcesPage_class=org.apache.wicket.examples.events.DecoupledAjaxUpdatePage
  for a good example.
 
  Best,
  Marvin
 
  -Original Message-
  From: Tobias Soloschenko [mailto:
  tobiassolosche...@googlemail.com]
  Sent: Tuesday, September 09, 2014 11:31 AM
  To: users@wicket.apache.org
  Subject: Re: Global Ajax Event Handler
 
  Hi,
 
  thanks for the answer, but this is only a client side event
  hook
  not
  for
  processing a request to the Server. I added a pseudo code
  to
  the
  question
  of martin who asked me what I exactly want to do.
 
  Thanks anyway for the fast answer!
 
  kind regards,
 
  Tobias
 
  Am 09.09.2014 um 11:06 schrieb Tom Götz t...@decoded.de
  :
 
  See
  https://cwiki.apache.org/confluence/display/WICKET/Wicket+Ajax
  ,
  section Global Ajax call listeners“.
 
  Cheers,
   -Tom
 
 
  On 09.09.2014, at 10:58, Tobias Soloschenko 
  tobiassolosche...@googlemail.com wrote:
 
  Hi all,
 
  is there a way to register a global ajax event handler
  within
  Wicket?
  For normal there is the AbstractDefaultAjaxBehavior which
  is
  added
  to a
  component. And then the CallbackScript can be obtained and
  used
  within
  a
  OnDomReadyHeaderItem for example.
 
  Is there a way to do this on application level so that
  Im
  able
  to
  get
  the CallbackScript from the instantiated Application?
 
  kind regards
 
  Tobias
  -
  To unsubscribe, e-mail:
  users-unsubscr...@wicket.apache.org
  For additional commands, e-mail:
  users-h...@wicket.apache.org
  -
  To unsubscribe, e-mail:
  users-unsubscr...@wicket.apache.org
  For additional commands, e-mail:
  users-h...@wicket.apache.org
 

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




Re: Global Ajax Event Handler

2014-09-09 Thread Tobias Soloschenko
 =
 session.getPageManager().get(parameters.get(pageId))
 target = webApplication.newAjaxRequestTarget(page)
 requestCycle.scheduleRequestHandlerAfterCurrent(target);
 page.send(page, Broadcast.BREADTH, new SomeEvent(target))
 
 in SomeComponent#onEvent() use
 someEvent.getTarget().add(this)
 to
 add
 the
 component when SomeEvent is broadcasted
 
 Martin Grigorov
 Wicket Training and Consulting
 https://twitter.com/mtgrigorov
 
 
 On Tue, Sep 9, 2014 at 12:40 PM, Richter, Marvin 
 marvin.rich...@freenetdigital.com wrote:
 
 What you are looking for is the Wicket Event mechanism.
 
 This allows you to send a broadcast to a specified
 Component
 (e.g.
 the
 current page) and a payload (e.g. your custom event type
 which
 contains
 information).
 
 In the Components which should react on the event you
 override
 the
 method
 onEvent, check if the event is of your type and if so, do
 with
 the
 event
 payload whatever you want.
 
 Check out
 http://www.wicket-library.com/wicket-examples/events/wicket/bookmarkable/org.apache.wicket.examples.source.SourcesPage?1SourcesPage_class=org.apache.wicket.examples.events.DecoupledAjaxUpdatePage
 for a good example.
 
 Best,
 Marvin
 
 -Original Message-
 From: Tobias Soloschenko [mailto:
 tobiassolosche...@googlemail.com]
 Sent: Tuesday, September 09, 2014 11:31 AM
 To: users@wicket.apache.org
 Subject: Re: Global Ajax Event Handler
 
 Hi,
 
 thanks for the answer, but this is only a client side event
 hook
 not
 for
 processing a request to the Server. I added a pseudo code
 to
 the
 question
 of martin who asked me what I exactly want to do.
 
 Thanks anyway for the fast answer!
 
 kind regards,
 
 Tobias
 
 Am 09.09.2014 um 11:06 schrieb Tom Götz t...@decoded.de
 :
 
 See
 https://cwiki.apache.org/confluence/display/WICKET/Wicket+Ajax
 ,
 section Global Ajax call listeners“.
 
 Cheers,
 -Tom
 
 
 On 09.09.2014, at 10:58, Tobias Soloschenko 
 tobiassolosche...@googlemail.com wrote:
 
 Hi all,
 
 is there a way to register a global ajax event handler
 within
 Wicket?
 For normal there is the AbstractDefaultAjaxBehavior which
 is
 added
 to a
 component. And then the CallbackScript can be obtained and
 used
 within
 a
 OnDomReadyHeaderItem for example.
 
 Is there a way to do this on application level so that
 Im
 able
 to
 get
 the CallbackScript from the instantiated Application?
 
 kind regards
 
 Tobias
 -
 To unsubscribe, e-mail:
 users-unsubscr...@wicket.apache.org
 For additional commands, e-mail:
 users-h...@wicket.apache.org
 -
 To unsubscribe, e-mail:
 users-unsubscr...@wicket.apache.org
 For additional commands, e-mail:
 users-h...@wicket.apache.org
 
 -
 To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
 For additional commands, e-mail: users-h...@wicket.apache.org
 
 

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



RE: Global Ajax Event Handler

2014-09-09 Thread Richter, Marvin
That definitely sounds like a really odd use case or am I wrong?

Do you really want to generate the URL outside from the Wicket context?
I mean this is something which is heavily tied to wicket anyway so why not 
generating it inside it's context?
And where do you need/use the final generated URL? I guess inside the Wicket 
context ... 

Maybe you should rethinking your use case, I bet the problem you're trying to 
solve can be solved much, much easier!

Anyway .. wish you luck ;)

-Original Message-
From: Tobias Soloschenko [mailto:tobiassolosche...@googlemail.com] 
Sent: Tuesday, September 09, 2014 2:58 PM
To: users@wicket.apache.org
Subject: Re: Global Ajax Event Handler

Thats the point. It is not used within a Component / Behavior - so I cant use 
getPage() ...

 Am 09.09.2014 um 14:50 schrieb Martin Grigorov mgrigo...@apache.org:
 
 The UrlGenerator class is used somewhere where the Page is available, no ?
 In SomeComponent/SomeBehavior:
 
 UrlGenerator generator = new UrlGenerator(); Url url = 
 generator.generate(getPage().getPageId());
 
 Session.get().getPageManager().getPage(exisingAndNonExpiredPageId) is 
 the way to get a reference to the page.
 Wicket uses this API internally every time you click a link or button.
 
 Martin Grigorov
 Wicket Training and Consulting
 https://twitter.com/mtgrigorov
 
 
 On Tue, Sep 9, 2014 at 3:45 PM, Tobias Soloschenko  
 tobiassolosche...@googlemail.com wrote:
 
 And thats the question I was looking for - how do I get the current 
 page id within the class that generates the url which is no component 
 and the second question was how do I get the page to that id, because 
 (Page)
 WebSession.get().getPageManager().getPage(i.get()) returns null for 
 int i 0-10, event if I cleared the browsers cache / restarted the server.
 
 kind regards and big thanks for all the help!
 
 Tobias
 
 2014-09-09 14:28 GMT+02:00 Martin Grigorov mgrigo...@apache.org:
 
 Session#pageId is a counter that is used to give an id to the next
 created
 page.
 It is not the id of the currently used page!
 
 You will need to provide the pageId somehow to the class that 
 generates
 the
 url.
 
 Martin Grigorov
 Wicket Training and Consulting
 https://twitter.com/mtgrigorov
 
 
 On Tue, Sep 9, 2014 at 3:13 PM, Tobias Soloschenko  
 tobiassolosche...@googlemail.com wrote:
 
 The method getPage() is not available at the place where I'm 
 building
 the
 link - I'm not within a component and I try to get the page by 
 content
 of
 the session. :-)
 
 I didn't modified the Session - the pageId is stored in 
 org.apache.wicket.Session.pageId which is an AtomicInteger
 
 
 2014-09-09 14:06 GMT+02:00 Martin Grigorov mgrigo...@apache.org:
 
 Pass the pageId as a query string parameter.
 
 PageParameters params = new PageParameters(); params.set(pageId, 
 getPage().getPageId()); theUrlToTheReference = 
 requestCycle.urlFor(yourResRef, params);
 
 Then in the IResource (better extend AbstractResource) just read 
 it
 from
 the request parameters.
 
 Storing the pageId in the session is not OK because the user may 
 open
 two
 different pages in separate tabs/windows and this will break.
 
 
 Martin Grigorov
 Wicket Training and Consulting
 https://twitter.com/mtgrigorov
 
 
 On Tue, Sep 9, 2014 at 3:01 PM, Tobias Soloschenko  
 tobiassolosche...@googlemail.com wrote:
 
 Thanks again for the fast answer. My code now looks this way:
 
Field declaredField =
 WebSession.get().getClass().getSuperclass()
.getDeclaredField(pageId);
 
declaredField.setAccessible(true);
AtomicInteger i = (AtomicInteger) 
 declaredField.get(WebSession.get());
Page page = (Page) WebSession.get().getPageManager()
.getPage(i.get());
 
AjaxRequestTarget newAjaxRequestTarget =
 ((WebApplication)
 Application.get())
.newAjaxRequestTarget(page);
 
RequestCycle.get().scheduleRequestHandlerAfterCurrent(
newAjaxRequestTarget);
 
 I dont know how to get the current pageId but from the Session. 
 The
 page
 at
 this place is null. :-(
 
 
 
 2014-09-09 13:53 GMT+02:00 Martin Grigorov mgrigo...@apache.org:
 
 On Tue, Sep 9, 2014 at 2:05 PM, Tobias Soloschenko  
 tobiassolosche...@googlemail.com wrote:
 
 Hi again,
 
 I tried out that code you mentioned here.
 WebSession.get().getPageManager().getPage(int i) returns
 IManageablePage
 which is not applicable as argument for newAjaxRequestTarget.
 
 cast it
 it is known that in your environment you don't use any custom 
 IManageablePage/IRequestablePage impls (see IPageFactory)
 
 
 
 The second thing is how do I get the instance of a page by
 class
 with
 the
 last page id not from within a component (this would be simple
 getPage())?
 
 I didn't get this
 Please re-phrase
 
 
 
 2014-09-09 11:51 GMT+02:00 Martin Grigorov 
 mgrigo...@apache.org
 :
 
 I've re-read the message and I think I got it.
 What you really need is a mounted resource

Re: Global Ajax Event Handler

2014-09-09 Thread Tobias Soloschenko
The usecase requires it :-) I send an example to you.

I hope this will be possible because then you are also able to do ajax requests 
from embedded jsp files. :-D

thanks anyway! 

 Am 09.09.2014 um 16:29 schrieb Richter, Marvin 
 marvin.rich...@freenetdigital.com:
 
 That definitely sounds like a really odd use case or am I wrong?
 
 Do you really want to generate the URL outside from the Wicket context?
 I mean this is something which is heavily tied to wicket anyway so why not 
 generating it inside it's context?
 And where do you need/use the final generated URL? I guess inside the Wicket 
 context ... 
 
 Maybe you should rethinking your use case, I bet the problem you're trying to 
 solve can be solved much, much easier!
 
 Anyway .. wish you luck ;)
 
 -Original Message-
 From: Tobias Soloschenko [mailto:tobiassolosche...@googlemail.com] 
 Sent: Tuesday, September 09, 2014 2:58 PM
 To: users@wicket.apache.org
 Subject: Re: Global Ajax Event Handler
 
 Thats the point. It is not used within a Component / Behavior - so I cant use 
 getPage() ...
 
 Am 09.09.2014 um 14:50 schrieb Martin Grigorov mgrigo...@apache.org:
 
 The UrlGenerator class is used somewhere where the Page is available, no ?
 In SomeComponent/SomeBehavior:
 
 UrlGenerator generator = new UrlGenerator(); Url url = 
 generator.generate(getPage().getPageId());
 
 Session.get().getPageManager().getPage(exisingAndNonExpiredPageId) is 
 the way to get a reference to the page.
 Wicket uses this API internally every time you click a link or button.
 
 Martin Grigorov
 Wicket Training and Consulting
 https://twitter.com/mtgrigorov
 
 
 On Tue, Sep 9, 2014 at 3:45 PM, Tobias Soloschenko  
 tobiassolosche...@googlemail.com wrote:
 
 And thats the question I was looking for - how do I get the current 
 page id within the class that generates the url which is no component 
 and the second question was how do I get the page to that id, because 
 (Page)
 WebSession.get().getPageManager().getPage(i.get()) returns null for 
 int i 0-10, event if I cleared the browsers cache / restarted the server.
 
 kind regards and big thanks for all the help!
 
 Tobias
 
 2014-09-09 14:28 GMT+02:00 Martin Grigorov mgrigo...@apache.org:
 
 Session#pageId is a counter that is used to give an id to the next
 created
 page.
 It is not the id of the currently used page!
 
 You will need to provide the pageId somehow to the class that 
 generates
 the
 url.
 
 Martin Grigorov
 Wicket Training and Consulting
 https://twitter.com/mtgrigorov
 
 
 On Tue, Sep 9, 2014 at 3:13 PM, Tobias Soloschenko  
 tobiassolosche...@googlemail.com wrote:
 
 The method getPage() is not available at the place where I'm 
 building
 the
 link - I'm not within a component and I try to get the page by 
 content
 of
 the session. :-)
 
 I didn't modified the Session - the pageId is stored in 
 org.apache.wicket.Session.pageId which is an AtomicInteger
 
 
 2014-09-09 14:06 GMT+02:00 Martin Grigorov mgrigo...@apache.org:
 
 Pass the pageId as a query string parameter.
 
 PageParameters params = new PageParameters(); params.set(pageId, 
 getPage().getPageId()); theUrlToTheReference = 
 requestCycle.urlFor(yourResRef, params);
 
 Then in the IResource (better extend AbstractResource) just read 
 it
 from
 the request parameters.
 
 Storing the pageId in the session is not OK because the user may 
 open
 two
 different pages in separate tabs/windows and this will break.
 
 
 Martin Grigorov
 Wicket Training and Consulting
 https://twitter.com/mtgrigorov
 
 
 On Tue, Sep 9, 2014 at 3:01 PM, Tobias Soloschenko  
 tobiassolosche...@googlemail.com wrote:
 
 Thanks again for the fast answer. My code now looks this way:
 
   Field declaredField =
 WebSession.get().getClass().getSuperclass()
   .getDeclaredField(pageId);
 
   declaredField.setAccessible(true);
   AtomicInteger i = (AtomicInteger) 
 declaredField.get(WebSession.get());
   Page page = (Page) WebSession.get().getPageManager()
   .getPage(i.get());
 
   AjaxRequestTarget newAjaxRequestTarget =
 ((WebApplication)
 Application.get())
   .newAjaxRequestTarget(page);
 
   RequestCycle.get().scheduleRequestHandlerAfterCurrent(
   newAjaxRequestTarget);
 
 I dont know how to get the current pageId but from the Session. 
 The
 page
 at
 this place is null. :-(
 
 
 
 2014-09-09 13:53 GMT+02:00 Martin Grigorov mgrigo...@apache.org:
 
 On Tue, Sep 9, 2014 at 2:05 PM, Tobias Soloschenko  
 tobiassolosche...@googlemail.com wrote:
 
 Hi again,
 
 I tried out that code you mentioned here.
 WebSession.get().getPageManager().getPage(int i) returns
 IManageablePage
 which is not applicable as argument for newAjaxRequestTarget.
 
 cast it
 it is known that in your environment you don't use any custom 
 IManageablePage/IRequestablePage impls (see IPageFactory)
 
 
 
 The second thing is how do I get the instance of a page by
 class
 with
 the
 last page id