[
https://issues.apache.org/jira/browse/WICKET-1066?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Gerolf Seitz resolved WICKET-1066.
----------------------------------
Resolution: Duplicate
Assignee: Gerolf Seitz
duplicate of WICKET-1199
> Wicket-Ajax header always false with BaseWicketTester
> -----------------------------------------------------
>
> Key: WICKET-1066
> URL: https://issues.apache.org/jira/browse/WICKET-1066
> Project: Wicket
> Issue Type: Bug
> Components: wicket
> Affects Versions: 1.3.0-beta3, 1.3.0-beta4
> Reporter: David Shepherdson
> Assignee: Gerolf Seitz
> Fix For: 1.3.0-rc2
>
>
> The 'Wicket-Ajax' header is always missing when using BaseWicketTester, even
> when the request should be an AJAX request.
> The specific case we have is an AjaxLink that, when clicked, shows a modal
> window. We call BaseWicketTester's clickLink(String) method to simulate
> clicking the link. The link's onClick(...) method is called with an
> appropriate AjaxRequestTarget; however, ModalWindow's onBeforeRender() tests
> whether the request is an AJAX request (using
> ((WebRequest)getRequest()).isAjax()) and, if it's not, hides the content
> panel.
> The problem is that the isAjax() call tests whether the HttpServletRequest's
> 'Wicket-Ajax' header is present and 'true'; when running this code with
> BaseWicketTester, the header is never there, and so the modal window's
> content is never shown.
> We have worked around the problem by overriding clickLink(String, boolean)
> and setupRequestAndResponse() as follows:
> private boolean m_handlingAjaxRequest = false;
>
> @Override
> public synchronized void clickLink(String path, boolean isAjax)
> {
> m_handlingAjaxRequest = isAjax;
> super.clickLink(path, isAjax);
> m_handlingAjaxRequest = false;
> }
>
> @Override
> public synchronized WebRequestCycle setupRequestAndResponse() {
> WebRequestCycle result = super.setupRequestAndResponse();
> if (m_handlingAjaxRequest) {
> // Set AJAX header.
> getServletRequest().addHeader(
> "Wicket-Ajax", "true");
> // *Don't* copy it to the response, even though
> // MockWebApplication's setupRequestAndResponse() does.
> }
> return result;
> }
> (I found that if I copied the 'Wicket-Ajax' header to the response, as done
> by MockWebApplication's setupRequestAndResponse(), it caused all AJAX clicks
> to misbehave.)
> Hence, it would seem that if BaseWicketTester's clickLink(String, boolean)
> method were modified to set the 'Wicket-Ajax' header as appropriate, modal
> windows -- and, presumably, any other things that rely on the request
> returning true from isAjax() -- would work as expected.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.