Re: Render a Wicket page to a string for HTML email

2010-03-16 Thread rolandpeng
append some more information. After tracing the sessionId in live sessions. I found several id listed below: sessionId1=3F329131CF155AEAA4FB383AD854E510 (normal format,created by login) sessionId2=7cc3d77e_12766bcf8eb__7fff (strange,created by call render api) sessionId3=7cc3d77e_12766bcf8eb__7ff

Re: Render a Wicket page to a string for HTML email

2010-03-16 Thread rolandpeng
Thank you. I have tested your implementation class,but it still the same(live sessions increasing) while I call requestLogger.getLiveSessions(). Does anyone have other advice? Thank you so much in advance. Xavier López-2 wrote: > > Oops, forgot to mention that code has a pair of bugs in it. Her

Re: Render a Wicket page to a string for HTML email

2010-03-16 Thread Xavier López
Oops, forgot to mention that code has a pair of bugs in it. Here is the implementation i came up with : public class RenderHTMLUtils { public static String renderPage(Page page) { //get the servlet context WebApplication application = (WebApplication) WebApplication.get();

Re: Render a Wicket page to a string for HTML email

2010-03-16 Thread Xavier López
Here is another way I used when I was in need of this feature. This one simulates a request cycle. I don't know if you could adapt this to fit your needs (maybe doing the same, but with the real requestCycle instead) ? http://www.danwalmsley.com/2008/10/21/render-a-wicket-page-to-a-string-for-html

Re: Render a Wicket page to a string for HTML email

2010-03-16 Thread rolandpeng
That works , thank you! But I have another question: when I use requestLogger.getLiveSessions() to get the live sessions,the number of sessions always increased after I call the render api. Is it possible to render page of html source in the same session(not create a new one)? Thank you! Scott S

Re: Render a Wicket page to a string for HTML email

2008-11-06 Thread Scott Swank
Ours is running in a separate, non-Wicket process that just generates and sends e-mail, so there's nothing to step on. But otherwise yes, you would want to protect your ThreadLocal. On Thu, Nov 6, 2008 at 4:52 PM, cjlyth <[EMAIL PROTECTED]> wrote: > > Yeah this is about the same, I think you woul

Re: Render a Wicket page to a string for HTML email

2008-11-06 Thread cjlyth
Yeah this is about the same, I think you would still have to do it in its own thread. try { return Executors.newSingleThreadExecutor().submit( new Callable() { public S

Re: Render a Wicket page to a string for HTML email

2008-11-06 Thread Scott Swank
Here is a largely equivalent class that I created. It simply extends BaseWicketTester. public class PageRenderer extends BaseWicketTester { private final Locale locale; public PageRenderer(Locale locale) { this.locale = locale; } public PageRender

Re: Render a Wicket page to a string for HTML email

2008-11-06 Thread Peter Ertl
> final WebApplication app = (WebApplication)WebApplication.get(); this will not work reliably unless you created a new WicketTester before in your tests or are running inside a current request handled by WicketFilter (needed to initialize the ThreadLocal Application instance in Application

Re: Render a Wicket page to a string for HTML email

2008-11-06 Thread Peter Ertl
cool. let's put this to the wiki (or maybe org.apache.util.* ???) and help some people out there :-) Am 06.11.2008 um 23:01 schrieb cjlyth: getBinaryContent was not returning anything for me. When i simply changed it to return tester.getServletResponse().getDocument() everything seemed t

Re: Render a Wicket page to a string for HTML email

2008-11-06 Thread cjlyth
getBinaryContent was not returning anything for me. When i simply changed it to return tester.getServletResponse().getDocument() everything seemed to work. Here is the sample that works in a jUnit test, I have not yet integrated this into any real applications. public String renderPage

Re: Render a Wicket page to a string for HTML email

2008-11-05 Thread Peter Ertl
public String renderPageToString(final WebApplication application, final Page page) { try { return Executors.newSingleThreadExecutor().submit(new Callable() { public String call() throws Exception { final WicketTester tester = new WicketTes

Re: Render a Wicket page to a string for HTML email

2008-11-05 Thread Igor Vaynberg
that should do it for most cases. you might want to give wickettester the actual application object also. -igor On Wed, Nov 5, 2008 at 9:26 AM, Peter Ertl <[EMAIL PROTECTED]> wrote: > So would this be ok ?! > > (caution! untested!) > > >try >{ > final String html = Executors.newSingl

Re: Render a Wicket page to a string for HTML email

2008-11-05 Thread Peter Ertl
So would this be ok ?! (caution! untested!) try { final String html = Executors.newSingleThreadExecutor().submit(new Callable() { public String call() throws Exception { final WicketTester tester = new WicketTester(); tester.startPage(M

Re: Render a Wicket page to a string for HTML email

2008-11-05 Thread Igor Vaynberg
you still have to do it in a separate thread :) -igor On Wed, Nov 5, 2008 at 9:14 AM, Peter Ertl <[EMAIL PROTECTED]> wrote: > Won't it be easier / will it work to use WicketTester for this? > > > Am 05.11.2008 um 17:26 schrieb Igor Vaynberg: > >> make sure you do this in a thread other then the r

Re: Render a Wicket page to a string for HTML email

2008-11-05 Thread Peter Ertl
Won't it be easier / will it work to use WicketTester for this? Am 05.11.2008 um 17:26 schrieb Igor Vaynberg: make sure you do this in a thread other then the request thread so you dont mess up any threadlocals. -igor On Wed, Nov 5, 2008 at 2:22 AM, Jörn Zaefferer <[EMAIL PROTECTED]> wrote:

Re: Render a Wicket page to a string for HTML email

2008-11-05 Thread Igor Vaynberg
make sure you do this in a thread other then the request thread so you dont mess up any threadlocals. -igor On Wed, Nov 5, 2008 at 2:22 AM, Jörn Zaefferer <[EMAIL PROTECTED]> wrote: > No voodoo neccessary, got it working: > > protected String renderPage(Class pageClass, > PageParameters pageParam

Re: Render a Wicket page to a string for HTML email

2008-11-05 Thread James Carman
Is the setAjax(true) absolutely necessary in all cases? On Wed, Nov 5, 2008 at 5:22 AM, Jörn Zaefferer <[EMAIL PROTECTED]> wrote: > No voodoo neccessary, got it working: > > protected String renderPage(Class pageClass, > PageParameters pageParameters) { > >//get the servlet context

Re: Render a Wicket page to a string for HTML email

2008-11-05 Thread Peter Ertl
Great work! You should put this on the Wiki :-) Am 05.11.2008 um 11:22 schrieb Jörn Zaefferer: No voodoo neccessary, got it working: protected String renderPage(Class pageClass, PageParameters pageParameters) { //get the servlet context WebApplication applica

Re: Render a Wicket page to a string for HTML email

2008-11-05 Thread Jörn Zaefferer
No voodoo neccessary, got it working: protected String renderPage(Class pageClass, PageParameters pageParameters) { //get the servlet context WebApplication application = (WebApplication) WebApplication.get(); ServletContext context = application.

Re: Render a Wicket page to a string for HTML email

2008-11-04 Thread Igor Vaynberg
saving up vacation days for the caribbean baby :) -igor On Tue, Nov 4, 2008 at 9:55 AM, Martijn Dashorst <[EMAIL PROTECTED]> wrote: > Are you in New Orleans in some voodoo bar? Why not join us at ApacheCon? :) > > Martijn > > On Tue, Nov 4, 2008 at 10:43 AM, Igor Vaynberg <[EMAIL PROTECTED]> wro

Re: Render a Wicket page to a string for HTML email

2008-11-04 Thread Martijn Dashorst
Are you in New Orleans in some voodoo bar? Why not join us at ApacheCon? :) Martijn On Tue, Nov 4, 2008 at 10:43 AM, Igor Vaynberg <[EMAIL PROTECTED]> wrote: > without seeing your code we have to resort to waving a dead chicken in > front of our screens or making swags. > > -igor > > On Tue, Nov

Re: Render a Wicket page to a string for HTML email

2008-11-04 Thread Igor Vaynberg
without seeing your code we have to resort to waving a dead chicken in front of our screens or making swags. -igor On Tue, Nov 4, 2008 at 9:19 AM, Jörn Zaefferer <[EMAIL PROTECTED]> wrote: > Hi, > > I've found this article on how to render a page to a String: > http://www.danwalmsley.com/2008/10/