pass in a dummy application to tester -igor
On Mon, Aug 16, 2010 at 11:20 AM, Joe Hudson <joe.hud...@clear2pay.com> wrote: > Hi, > > First of all, before I get flamed - I've seen many topics about this since > I've been looking into this: > > http://www.mail-archive.com/users@wicket.apache.org/msg27512.html > http://www.danwalmsley.com/2008/10/21/render-a-wicket-page-to-a-string-for-html-email/ > http://apache-wicket.1842946.n4.nabble.com/Wicket-PDF-Page-Project-td1934168.html > > My problem is that I am trying to get the rendered contents of a Page to > hopefully post process it and make a PDF out of it (using Flying Saucer) - > because of this I need to reference the currently running application for the > WicketTester (otherwise the application properties aren't available) > > So, the standard WicketTester approach looks like this as far as I can tell: > public static String toString(Class<? extends Page> pageClass) { > final WicketTester renderer = new WicketTester((WebApplication) > Application.get()); > renderer.startPage(pageClass); > String renderedSource = renderer.getServletResponse().getDocument(); > return renderedSource; > } > > The problem with this approach is that the init method of the application now > runs twice (once when the app starts and once when this code runs). This is > causing an error because we are mounting resources which don't like being > mounted twice. > > I have tried the other approach suggested from Dan Walmsley and haven't had > any luck with this either - can anyone get this to work? Am I just making > this terribly hard on myself - is it really this complicated to render a Page > to a String? Thanks very much for any feedback you might be able to offer. > > Joe > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org