Wicket AjaxFallbackLink behaviour - wicket

I use the AjaxFallbackLink component for an Ajax link. When I mouse-over the link, the URL looks something like ./myPage?1-1.ILinkListener-xxx. And when I actually click the link, however, the Ajax request looks something like: ./myPage?1-1.IBehaviorListener-xxx.
It seems that Wicket JavaScript has somehow changed the URL from ILinkListener to IBehaviorListener. Wonder if it is so, and why is that?
Sometimes in certain circumstances ILinkListener in the URL is not changed to IBehaviorListener when the request is sent out by the browser, which causes NullPointerException as parameter AjaxRequestTarget target in the callback function is null. I haven't been able to reproduce this. Just wonder what browser settings could cause this to happen. Thanks a lot.

Both of those URLs are correct.
The first static link address './myPage?1-1.ILinkListener-xxx.' is a generic link address for a link in case it invokes a URL and process the link.
The second AJAX link address './myPage?1-1.IBehaviorListener-xxx' is a generic JavaScript/AJAX behavior. In case when JavaScript is working, the JavaScript is attached as an onclick event (see jQuery click() function at https://api.jquery.com/click/) and it processes the link, then it shouldn't continue to process the URL from HREF attribute.
So far you would expect to request only one of those URLs when the link is clicked. But in case of AjaxFallbackLink when there is no AJAX then onClick(AjaxRequestTarget) is invoked as onClick(null), it causes NPE if you rely on existing AjaxRequestTarget object, but there is no guarantee for that.
The last part of your question is not clear when it is not possible to reproduce. But Wicket uses jQuery, if you add jQuery library into the HTML, there is a possible conflict of versions.
There are some more detail on a similar issue at http://apache-wicket.1842946.n4.nabble.com/AjaxFallbackLink-s-onClick-with-null-AjaxRequestTarget-migrating-1-4-to-6-td4652143.html

Related

Assert Request URL is specified URL using Protractor

Does Protractor provide a native way to check requests going out from events such as a button click?
For example, onClick(), a POST request is made to https://myapi.net/customers and I'd like to, during my test, make an assertion on the Request URL.
I've seen some npm packages that might be provide some help, but looking through the Protractor API's, I can't seem to find anything that would handle this out of the box.
Thanks!
One simple way to do is to use browser.driver.getCurrentUrl()
Preceding approach will provide the current url on browser but if you are interested in url which is triggered after click button then i am not aware how we deal this in webdriverJs but in .Net there is Support.Event namespace which provide the way to do action after ElementClicked event.

AEM 6.2: Using LinkTransformer - How is it triggered?

I am looking at an Adobe forum post where the link rewrite is happening. How is the LinkTransformer class triggered? For example if I am testing this in local, and put a debug inside the class does a page refresh get to this class?
Thanks..
The Link Transformer will run on every request that renders HTML. It is used to rewrite all of the configured HTML elements.
It will for example rewrite the href attribute of all <a> HTML tags. But there are several more HTML elements and attributes that are rewritten.
So in theory your debugger should halt at a breakpoint on every request. (Except if you call the page through the Dispatcher which usually will cache the HTML after the first request. So every subsequent request would not be answered by AEM and therefore, the debugger will not halt.)

How to secure querystring/POST details to a third party

I'm basically looking at a security problem between a parent page and an iframe with links to a third party.
I want to send a POST or a GET (doesn't matter which as I can control the other side) to the third party, but not expose any details within it (say a SID or a user token) and have it's HTML content (JS/HTML/Images) loaded into the iframe.
I've looked at server-side redirects, creating a proxy using webclinet/webresponse and am curious to whether there is a good way to do it.
Has anyone ever done this before, or think that the secrity is not possible? Hell, even if I'm barking up the wrong tree on how to solve this.
If anybody has any examples on this it would be greatly appreciated.
Cheers,
Jamie
[Edit] Was thinking I might need to add some more details.
Say I have a parent page: https://mycompany.com/ShowThirdParty.
This has an iframe in it at the moment which will have the content of another component (also owned by me, or another team more specifically)
Basically I'd like to send some credentials to content in the iframe in such a way that the external pages can't read it, the iframe is put into a modal (I've done that) and the iframe has the restricted content with the auhtentication almost seamless and invisible.
I currently have it working as a GET url generated dynamically via JS and then passed into the iframe src parameter, obviously that isn't secure.
I kind of want some kind of server side redirect across a full url, but I don't even think that's possible.
You could try using AJAX and load a PHP script (with any parameters to the script encoded/encrypted) to query the 3rd party page and load the response into the iframe. Not really sure how your code is setup but there should be a way.
It can also be done by POST Method (submit the data to iFrame using POST) as it is HTTPS so the data you send to iFrame is encryped.

liftweb S.error redirects to previous page

I'm currently working with lift and I recently faced a difficult with redirects.
When I try to show an error or notice with S.error, it redirects to the page which I was previously. And I couldn't find a work around for that. I assume it's a default behavior of lift and there should be a work around. Please post how to changed this behavior.
It's unlikely that S.error is causing the redirect.
I presume you're calling S.error while processing a form submission. If so, you need to call S.redirectTo or S.seeOther after your processing is complete to redirect the browser to a different page. If you don't Lift's default behaviour is to reload the form on which you have just clicked submit.

Can I get the source of the current Wicket Page?

I've been using wicketTester.getServetResponse.getDocument to get the text of the current page for testing, only to find that after an ajax request it is set to the ajax response, not the whole page.
Is there any way to get a representation of the whole rendered page, as the browser would be seeing it after the ajax manipulation?
With WicketTester, you can simulate an Ajax call and see that your app sends the correct Ajax response. But it doesn't really exercise the ajax.
So I don't believe there's a way to get that from WicketTester.
If you actually need to test the app all the way to the UI including Ajax/javascript effects on the rendering, you likely need to use something like Selenium for that portion of your testing.
Thinking the Wicket way I hope the following approach should work:
#startPage(YourPage.class)
do some Ajax calls
#startPage(wicketTester.getLastRenderedPage())
wicketTester.getLastRenderedPageAsString()
The idea is: you start a page for testing, the first response is complete page response, then you do some Ajax calls which change some models around, then you start the last rendered page as an instance - this way it will render the page with the updated models from the Ajax calls.
The trouble is that you can put any Javascript in the response to an Ajax call. But if you don't want to deal with that, you can save the original full-page DOM, iterate through the objects in the Ajax response, find them by id in the full DOM and replace them with the new versions.
How useful this would be, I don't know, my guess would be not very. so I'd probably go with Selenium too.