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 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/bookmarka > > >>> ble/org.apache.wicket.examples.source.SourcesPage?1&SourcesPage_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 > > > > > > > > > B‹KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKCB• È > > [œÝXœØÜšX™K K[XZ[ ˆ \Ù\œË][œÝXœØÜšX™P ÚXÚÙ] ˜\ XÚ K›Ü™ÃB‘›Üˆ Y ] [Û˜[ > > ÛÛ[X[™ Ë K[XZ[ ˆ \Ù\œËZ [ ÚXÚÙ] ˜\ XÚ K›Ü™ÃBƒ > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > > For additional commands, e-mail: users-h...@wicket.apache.org > > > > >