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
     <div id="container">

Simplified html output in 1.5
     <div id="container">

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) {
      add(new WebMarkupContainer(tagId) {

       protected void onRender(MarkupStream markupStream) {
        try {
         WebRequestCycle cycle = (WebRequestCycle) RequestCycle.get();
         ServletRequest request =
         ServletResponse response =
         ServletContext context = ((WebApplication)
         RequestDispatcher rd = context.getNamedDispatcher(servletName);
         if (rd != null) {
          rd.include(request, response);
         } else {
          // handling...
        } catch (Exception e) {
         // handling...

    public class WrapperPanel extends AbstractServletWrapperPanel {
     private static final long serialVersionUID = 1L;

     public WrapperPanel(String id, final String servletName) {
      super(id, servletName, "wrappedContentId");

    //WrapperPanel html
      <wicket:container wicket:id="wrappedContentId"/>

In the 1.5 version I'm getting the request and response via
* (HttpServletRequest)RequestCycle.get().getRequest().getContainerRequest()

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
  * Note: To invoke onComponentTagBody() I had to open up the container tag
  * 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
* 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
* 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

I also posted this question on SO,

Any help solving this issue would be very appreciated!



Reply via email to