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
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) ?
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();
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. Here
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)
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
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
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
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
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 CallableString() {
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 would
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? extends Page pageClass,
PageParameters pageParameters) {
//get the servlet context
No voodoo neccessary, got it working:
protected String renderPage(Class? extends Page pageClass,
PageParameters pageParameters) {
//get the servlet context
WebApplication application = (WebApplication)
WebApplication.get();
ServletContext context
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? extends Page pageClass,
PageParameters pageParameters) {
//get the servlet
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? extends Page pageClass,
PageParameters
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:
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 request
So would this be ok ?!
(caution! untested!)
try
{
final String html =
Executors.newSingleThreadExecutor().submit(new CallableString()
{
public String call() throws Exception
{
final WicketTester tester = new WicketTester();
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 =
public String renderPageToString(final WebApplication application,
final Page page)
{
try
{
return Executors.newSingleThreadExecutor().submit(new
CallableString()
{
public String call() throws Exception
{
final WicketTester tester = new
Hi,
I've found this article on how to render a page to a String:
http://www.danwalmsley.com/2008/10/21/render-a-wicket-page-to-a-string-for-html-email/
It seemed to be exactly what I was looking for. Copying the code into
my app, I got a compiler error on the line where the WebRequest is
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:
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 4,
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] wrote:
24 matches
Mail list logo