* John Krasnay:
> OK, so WicketTester is the way to go. JBQ's response implied that there
> was a more direct way to do it, but I'll give WicketTester a try.

Yes there is a more direct way.  I'm sorry I made an error, I
meant StringResponse, not StringRequestTarget.  I spent a few
minutes writing the example, as this is a recurring question, here
it is:

http://svn.apache.org/viewvc/incubator/wicket/trunk/jdk-1.5/wicket-examples/src/main/java/org/apache/wicket/examples/staticpages/Application.java?revision=550248&view=markup

Look at the very bottom, where I'm using a custom
BookmarkablePageRequestTarget:

new BookmarkablePageRequestTarget(Page.class, params) {
        /**
         * @see 
org.apache.wicket.request.target.component.BookmarkablePageRequestTarget#respond(org.apache.wicket.RequestCycle)
         */
        @Override
        public void respond(RequestCycle requestCycle)
        {
                if (requestParams.getString("email") != null) {
                        final StringResponse emailResponse = new 
StringResponse();
                        final WebResponse originalResponse = 
(WebResponse)RequestCycle.get().getResponse();
                        RequestCycle.get().setResponse(emailResponse);
                        super.respond(requestCycle);
                        // Here send the email instead of dumping it to stdout!
                        System.out.println(emailResponse.toString());
                        RequestCycle.get().setResponse(originalResponse);
                        RequestCycle.get().setRequestTarget(new 
BookmarkablePageRequestTarget(Sent.class));
                } else {
                        super.respond(requestCycle);
                }
        }
};

The example can be found in latest wicket examples in the
"staticpages" demo.
-- 
     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