AEM 6.2: Using LinkTransformer - How is it triggered? - aem

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.)

Related

Wicket AjaxFallbackLink behaviour

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

check user availability in forms in jsp

I have a jsp form which takes in user details. On submit button it goes to a jsp page where the details are entered into the database. But before that I would like to check if the username is available as soon as the user clicks the check availability button. How can this be done?
2 ways:
Just redisplay the same page after submitting the form wherein you conditionally display the validation message. This is rather trivial and already covered in the Hello World example in our Servlets wiki page.
Use Ajax to send an asynchronous HTTP request and manipulate the HTML DOM based on the response of the request. This requires a bit more in depth understanding of how websites really work and what JavaScript is. You can find some concrete examples in How to use Servlets and Ajax?
Use AJAX(Asynchronous Javascript and Xml). Its the best web2.0 technology. You can manipulate DOM based on the answer from server

ASP Classic - Passing form data to Iframe

I'm looking to pass data from a form into an iFrame, but I have a slight problem.
The form page I can edit with no restrictions
The page I send the data to I cannot edit unless its html or JavaScript
The data needs to end up in an iframe within this page, which I can edit with no restrictions
I'm incorporating a search function into a CMS system which is why I cannot edit the iframe's parent page, and why I am using iframes at all.
At the moment the data sends to the parent page but is not picked up within the iframe, I am sending via the POST method.
I got it..
Added and extra page which converted the post data into session data,
if anyone knows a better way i would like to hear it though.
And they are the same domain, but editing the CMS system would have taken ages to look through as its not mainstream or developed by me.
Maybe I'm oversimplifying the problem, but can't you use the "target" attribute of the form tag to post to the Iframe?

<fb:comment> tag not working properly

I have a GWT app and Im trying to put fb social plugin comment in side of my page. However I have the folowing problem.
If I put the tag in my .html it works perfect, but If I put id dynamically (like with an HTML widjet), It does not work. It just does not display anything.
Can anyone help me? Im having this problem in general, not only with the fb:comment tag.
Note: If I use the iframe implementation of, for example, "fb:like", it works perfect.
My understanding of facebook's api is that it loads your content, and parses out the tags in the fb namespace, replacing them before the actual content is drawn for the user. In contrast, none of the GWT compiled code (or indeed any Javascript code) gets a chance to make changes to the dom until the page has loaded in the browser fully, after facebook has made the changes it needs to.
My advice: Put the fb namespaced tags on the initial page, but perhaps wrap them in a div and mark them as display:none. Then you can grab them from your GWT code and wrap them up in a widget, only to be displayed when you are ready.

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.