* Jeremy Thomerson:
> I hope someone can give me a hand.  I'm trying to do something similar, and
> seemingly stumped.
> 
> I have a form that I want to have the user fill out, and then I just want to
> email the completed form to someone on our team.  So, I created subclasses
> of form components that can be switched from "edit" to "view" mode, and that
> works great.  So, I submit the form, and swap them out to "view" mode so
> that it is the exact same form, except instead of text fields and the like,
> I then have labels that display the input, in an un-editable way.
> 
> Now, the problem: In the onSubmit() of my Button, I switch the fields over,
> and then I would like to render the page to a String and email it, and then
> render the page for the user.
> 
> I've tried the methods below, and both are failing - can someone please
> help.
> 
> First, I tried JBQ's method, slightly modified since I'm not in a request
> target.  Maybe that's the problem.  Maybe I need to specifically mount this
> page to a request strategy as he does in the example.  But, I'd rather be
> able to accomplish this in the form itself.
> 
>    final StringResponse emailResponse = new StringResponse();
>    final WebResponse originalResponse =
> (WebResponse)RequestCycle.get().getResponse();
>    RequestCycle.get().setResponse(emailResponse);
>    RequestCycle.get().getRequestTarget().respond(RequestCycle.get());
>    // Here send the email instead of dumping it to stdout!
>    System.out.println(emailResponse.toString());
>    RequestCycle.get().setResponse(originalResponse);
>    RequestCycle.get().setRequestTarget(new BookmarkablePageRequestTarget(
> Home.class));
> 
> I get this error (BTW - I'm on 1.2.6 with this app until we have an RC
> release):
> 
> Caused by: java.lang.ClassCastException: wicket.response.StringResponse
>    at wicket.protocol.http.WebRequestCycle.getWebResponse(
> WebRequestCycle.java:110)
>    at wicket.markup.html.WebPage.configureResponse(WebPage.java:249)
>    at wicket.markup.html.pages.ExceptionErrorPage.configureResponse(
> ExceptionErrorPage.java:106)
>    at wicket.Page.onRender(Page.java:854)
>    at wicket.Component.render(Component.java:1526)
>    at wicket.Page.renderPage(Page.java:408)
>    at wicket.request.target.component.PageRequestTarget.respond(
> PageRequestTarget.java:67)
>    at wicket.request.compound.DefaultResponseStrategy.respond(
> DefaultResponseStrategy.java:49)
>    at wicket.request.compound.AbstractCompoundRequestCycleProcessor.respond
> (AbstractCompoundRequestCycleProcessor.java:66)
>    at wicket.RequestCycle.respond(RequestCycle.java:950)
>    at wicket.RequestCycle.step(RequestCycle.java:1025)

It's not your fault.  I didn't mention that you need to upgrade to
the latest beta2 for this to work, as there is a nasty cast to
WebResponse in WebPage.java that I removed.
-- 
     Jean-Baptiste Quenot
aka  John Banana   Qwerty
http://caraldi.com/jbq/

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to