0

I need to create a bunch of html mails with Wicket. But afaik Wicket requires a servlet context.

So I'm looking for a way to use Wicket as a simple renderer for html. That is, render my Page objects, without having to start up a servlet engine.

In essence:

 String renderPageToHtml (Page page) { 
     /* 
        1. Instantiate wicket. 
        2. Render page to String
        3. Return it.
      */
 }
Martin Wickman
  • 19,662
  • 12
  • 82
  • 106
  • Possible duplicate of http://stackoverflow.com/questions/7068429/wicket-how-to-render-page-programmatically-and-get-result-as-string/7069115#7069115 – biziclop Oct 16 '12 at 10:54

1 Answers1

5

Not tested it, but you might try the WicketTester. This class is actually for resting, but allows to instantiate Components without a servlet container.

WicketTester tester = new WicketTester(new MyApplication();
tester.startPage(MyPage.class);
String MyPageAsString = tester.getLastResponseAsString();

As I said, use at your own risk, I have not tested this.

bert
  • 7,566
  • 3
  • 31
  • 47