Search code examples
jspspring-mvcparametersdecoratorsitemesh

How to use printable view from siteMesh?


I am using siteMesh 2.4.2 with Spring Frameworks 4.1. The UI was built as head/content/footer style.

Which is fine for most situation. But When I try to generate a printable view, I found I can't do it, as all JSP were wrapped in that style.

How I can simply not apply SiteMesh decorators? But just request plain JSP directly without using MAV style to put everything in decorated frames.

EDIT

I tried follow instruction by

http://wiki.sitemesh.org/wiki/display/sitemesh/Decorating+Beyond+URL+Patterns

I added printable mapper to my sitemesh.xml as:

    <mapper class="com.opensymphony.module.sitemesh.mapper.PrintableDecoratorMapper">
        <param name="decorator" value="printable" />
        <param name="parameter.name" value="printable" />
        <param name="parameter.value" value="true" />
    </mapper>

and Then I add meta to my JSP header as:

<meta name="decorator" content="printable">

And I also tried to pass it as parameter in my controller such as:

 mav.setViewName("/WEB-INF/sitemesh-decorators/printableView.jsp?decorator=printable&");

The result is same, the frames (header, footer) are still here.

Any idea?? Please help!


Solution

  • After about couple of weeks thinking and trying, I nearly give up to get it fix.

    Accidentally, I found my printable JSP url is not my expected as I don't see the parameter "printable=true". Suddenly, I found out why, this may help some one else who is in my situation.

    In my situation, I used ModelAndView to bring up the my printable view from Spring MVC controller by using ".setViewName" call and I put the parameter in to my JSP by appended "printable=true" at the end. This is totally wrong.

    The correct way is: Have to put the "printable=true" at the end of request mapping path when I call the controller from other JSP. When I did it, printable view was displayed as I expected.

    This is what looks like:

    <a class="button" href="${pageContext.request.contextPath}/printPlacementEntityByPartner?placementIdKey=${placemententity.placementId}&printable=true&">
    

    Hope this will help some one else when who in my situation.