Hi! Seven days ago I posted a question on the users mailing list (see below), but I have got no responses so far. I thought I'll give it a try with the developers list as well. Since my question to the users list I also found that our 1.4 approach is very much alike what's described on the Wicket wiki https://cwiki.apache.org/WICKET/including-jsp-files-in-html-templates.html. So there might be more projects bumping into this issue soon.
I also posted this question on SO, http://stackoverflow.com/questions/9257706/wicket-1-5-and-jsp-servlet-wrapping Thanks, Johan ---------- Forwarded message ---------- From: Johan Isaksson <[email protected]> Date: 2012/2/14 Subject: Wicket 1.5 and JSP/servlet wrapping To: [email protected] Hi! In the project I'm on we want to upgrade from Wicket 1.4 to 1.5 (1.5.4) and one major thing is not working yet. There's a need to wrap old JSP/servlets into the new Wicket based application and the old 1.4-approach is not working anymore. Simplified html output in 1.4 <body> <div id="container"> wrappedContentFromJsp </div> <body> Simplified html output in 1.5 <body> wrappedContentFromJsp <div id="container"> </div> <body> So, all the JSP content renders outside the tag that we like to wrap it in. The wrapping magic happens in our internal AbstractServletWrapperPanel and the WebMarkupContainer.onRender(MarkupStream markupStream) override. However, in Wicket 1.5 we can't invoke markupStream.next() since it's no longer provided. I have not found a way around this yet. Working code for 1.4 with a sample panel implementation as reference: public abstract class AbstractServletWrapperPanel extends Panel { public AbstractServletWrapperPanel(String id, final String servletName, String tagId) { super(id); add(new WebMarkupContainer(tagId) { @Override protected void onRender(MarkupStream markupStream) { markupStream.next(); try { WebRequestCycle cycle = (WebRequestCycle) RequestCycle.get(); ServletRequest request = cycle.getWebRequest().getHttpServletRequest(); ServletResponse response = cycle.getWebResponse().getHttpServletResponse(); ServletContext context = ((WebApplication) Application.get()).getServletContext(); RequestDispatcher rd = context.getNamedDispatcher(servletName); if (rd != null) { rd.include(request, response); } else { // handling... } } catch (Exception e) { // handling... } } }); } } //Impl public class WrapperPanel extends AbstractServletWrapperPanel { private static final long serialVersionUID = 1L; public WrapperPanel(String id, final String servletName) { super(id, servletName, "wrappedContentId"); } } //WrapperPanel html <body> <wicket:panel> <wicket:container wicket:id="wrappedContentId"/> </wicket:panel> </body> In the 1.5 version I'm getting the request and response via * (HttpServletRequest)RequestCycle.get().getRequest().getContainerRequest() * (HttpServletResponse)RequestCycle.get().getResponse().getContainerResponse() Then I've tried to: * use the onRender()-magic without markupStream.next() that's no longer provided in 1.5 * move it to onComponentTagBody(MarkupStream markupStream, ComponentTag tag) * Note: To invoke onComponentTagBody() I had to open up the container tag "<wicket:container></wicket:container>". * I also tried without invoking markupStream.next() as that step is performed in Component.internalRenderComponent() just before onComponentTagBody is invoked at all. * move it to onComponentTag(ComponentTag tag) * combined above with setting setRenderBodyOnly(true) in the WebMarkupContatiner.onInitialize() * use a <div> tag instead of a wicket:container * use debug mode to track down the rendering process of 1.5. But still, I guess I'm missing out some key part of the new 1.5 way of rendering components. * invoke getAssociatedMarkupStream() from onRender() but that raises the following error * org.apache.wicket.markup.MarkupNotFoundException: Markup of type 'html' for component '... AbstractServletWrapperPanel$1' not found. Since it's not an option to migrate all that JSP functionality to Wicket anytime soon this is kind of a showstopper for us at the moment. For reference, the 1.4 way of doing this is much similar to the approach I found in the article http://herebebeasties.com/2007-03-01/jsp-and-wicket-sitting-in-a-tree/ I also posted this question on SO, http://stackoverflow.com/questions/9257706/wicket-1-5-and-jsp-servlet-wrapping Any help solving this issue would be very appreciated! Thanks, Johan
