because of all the threadlocals you should probably run wickettester in a
separate thread:

onclick() {
 final String[] output=new String[1];
 Runnable gen=new Runnable() {
   run() {
      WicketTester tester=new WicketTester();
      tester.startPage(new MailPage());
      output[0]=tester.getoutput();
     }
   }
   Thread thread=new Thread(gen);
   thread.start();
   thread.join();
   // output available in output[0]
 }
}

-igor


On 7/26/07, Tremelune <[EMAIL PROTECTED]> wrote:
>
>
> This issue is ultimately stemming from a specific issue I encountered
> during
> my trials and tribulations in
>
> http://www.nabble.com/How-to-get-HTML-source-code-from-a-wicket-page-tf3968790.html#a11548230
> this thread , but it was getting buried a bit in the rest of the
> thread...I
> figured I'd ask with a more specific title.
>
> Essentially, I'm trying to use WicketTester to hit a page in order to get
> the page's final rendered HTML (so I can use it in an email). It works,
> but
> within the process the object in RequestCycle.current disappears for some
> reason. The initial page that is being processed explodes. Is there
> something I can do to prevent this? I tried instantiating a new
> WebRequestCycle, but it resulted in an infinite loop (perhaps I
> constructed
> it poorly, though)...
>
>
> A snippet:
>
> class SomePage extends WebPage {
>   public SomePage() {
>     CaptureApplication app = new CaptureApplication();
>     WicketTester tester = new WicketTester(app);
>     tester.startPage(AnotherPage.class);
>
>     //Everything's fine through here...but after...ASSPLODE!
>   }
>
>
>
>   class CaptureApplication extends WebApplication {
>     public Class getHomePage() {
>       return null;
>     }
>
>     protected IRequestCycleProcessor newRequestCycleProcessor() {
>       return new InterceptingCycle();
>     }
>
>     class InterceptingCycle extends WebRequestCycleProcessor {
>       public void respond(RequestCycle requestCycle) {
>         StringResponse emailResponse = new StringResponse();
>         WebResponse originalResponse = (WebResponse)
> RequestCycle.get().getResponse();
>         RequestCycle.get().setResponse(emailResponse);
>
>         super.respond(requestCycle);
>
>         System.out.println(emailResponse.toString());
>
>         RequestCycle.get().setResponse(originalResponse);
>       }
>     }
>   }
> }
>
> --
> View this message in context:
> http://www.nabble.com/RequestCycle-goes-null-after-using-WicketTester-within-Wicket-page-tf4153591.html#a11817296
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> -------------------------------------------------------------------------
> This SF.net email is sponsored by: Splunk Inc.
> Still grepping through log files to find problems?  Stop.
> Now Search log events and configuration files using AJAX and a browser.
> Download your FREE copy of Splunk now >>  http://get.splunk.com/
> _______________________________________________
> IMPORTANT NOTICE:
>
> This mailing list is shutting down. Please subscribe to the Apache Wicket
> user list. Send a message to: "users-subscribe at wicket.apache.org" and
> follow the instructions.
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
IMPORTANT NOTICE:

This mailing list is shutting down. Please subscribe to the Apache Wicket user 
list. Send a message to: "users-subscribe at wicket.apache.org" and follow the 
instructions.
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to