[ 
https://issues.apache.org/jira/browse/WICKET-2944?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12896365#action_12896365
 ] 

Martin Grigorov commented on WICKET-2944:
-----------------------------------------

As the exception message says currently 
AjaxRequestTarget$AjaxHeaderResponse.renderJavascriptReference() and few other 
methods throw exception if they are not called within 
org.apache.wicket.ajax.AjaxRequestTarget.respondHeaderContribution(Response, 
Component).

I see two solutions:
# instead of throwing an exception just log a debug message that this call is 
no-op for AjaxRequestTarget$AjaxHeaderResponse when called for application 
listeners
Pros:
* no such "strange" exceptions during Ajax calls
Cons:
* none
# support these methods to be called for application listeners
Pros:
* no exceptions
Cons:
* there is no need to support them. These methods already have been called for 
the page (non-ajax) request and there is no need to make <header-contribution> 
for them which will be discarded.

I'm going to implement solution 1 if there are no better ideas.

> Application addRenderHeadListener causing error 
> ------------------------------------------------
>
>                 Key: WICKET-2944
>                 URL: https://issues.apache.org/jira/browse/WICKET-2944
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.4.9
>         Environment: wicket 1.4.9 jetty 6.1.4
>            Reporter: vineet semwal
>            Assignee: Martin Grigorov
>         Attachments: quickie.jar
>
>
> when i try to use addrenderheaderlistener in application  with header 
> contributor using methods other than renderonloadjavascript and
>  renderOnDomReadyJavascript,i get the  exception as ajaxrequesttarget expects 
>  "Only methods that can be called on IHeaderResponse outside renderHead() are 
> renderOnLoadJavascript and renderOnDomReadyJavascript
> attaching a quickstart that shows the behavior where ajaxselfupdatingtimer is 
>  used. 
> exception as follows :-
> Only methods that can be called on IHeaderResponse outside renderHead() are 
> renderOnLoadJavascript and renderOnDomReadyJavascript
> org.apache.wicket.WicketRuntimeException: Only methods that can be called on 
> IHeaderResponse outside renderHead() are renderOnLoadJavascript and 
> renderOnDomReadyJavascript
>       at 
> org.apache.wicket.ajax.AjaxRequestTarget$AjaxHeaderResponse.checkHeaderRendering(AjaxRequestTarget.java:872)
>       at 
> org.apache.wicket.ajax.AjaxRequestTarget$AjaxHeaderResponse.renderJavascriptReference(AjaxRequestTarget.java:915)
>       at 
> com.mycompany.WicketApplication$1.renderHead(WicketApplication.java:28)
>       at 
> org.apache.wicket.Application.notifyRenderHeadListener(Application.java:1250)
>       at 
> org.apache.wicket.markup.html.internal.HeaderResponse.<init>(HeaderResponse.java:56)
>       at 
> org.apache.wicket.ajax.AjaxRequestTarget$AjaxHeaderResponse.<init>(AjaxRequestTarget.java:951)
>       at 
> org.apache.wicket.ajax.AjaxRequestTarget.getHeaderResponse(AjaxRequestTarget.java:1018)
>       at 
> org.apache.wicket.ajax.AbstractAjaxTimerBehavior.respond(AbstractAjaxTimerBehavior.java:163)
>       at 
> org.apache.wicket.ajax.AbstractDefaultAjaxBehavior.onRequest(AbstractDefaultAjaxBehavior.java:286)
>       at 
> org.apache.wicket.request.target.component.listener.BehaviorRequestTarget.processEvents(BehaviorRequestTarget.java:119)
>       at 
> org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:92)
>       at 
> org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1250)
>       at org.apache.wicket.RequestCycle.step(RequestCycle.java:1329)
>       at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1428)
>       at org.apache.wicket.RequestCycle.request(RequestCycle.java:545)
>       at 
> org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:479)
>       at 
> org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:312)
>       at 
> org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1157)
>       at 
> org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:388)
>       at 
> org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
>       at 
> org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
>       at 
> org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
>       at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:418)
>       at 
> org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
>       at 
> org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
>       at 
> org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
>       at org.mortbay.jetty.Server.handle(Server.java:326)
>       at 
> org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
>       at 
> org.mortbay.jetty.HttpConnection$RequestHandler.headerComplete(HttpConnection.java:923)
>       at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:547)
>       at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
>       at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
>       at 
> org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
>       at 
> org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to