Return to correct page when user tries to post an empty post.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 19 Oct 2010 20:35:36 +0000 (22:35 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 19 Oct 2010 20:35:36 +0000 (22:35 +0200)
src/main/java/net/pterodactylus/sone/web/CreatePostPage.java
src/main/resources/templates/createPost.html

index d2bd5da..05aceac 100644 (file)
@@ -51,6 +51,7 @@ public class CreatePostPage extends SoneTemplatePage {
        @Override
        protected void processTemplate(Request request, Template template) throws RedirectException {
                super.processTemplate(request, template);
+               template.set("returnPage", request.getUri());
                if (request.getMethod() == Method.POST) {
                        String text = request.getHttpRequest().getPartAsStringFailsafe("text", 65536).trim();
                        String returnPage = request.getHttpRequest().getPartAsStringFailsafe("returnPage", 64);
@@ -60,7 +61,9 @@ public class CreatePostPage extends SoneTemplatePage {
                                throw new RedirectException(returnPage);
                        }
                        template.set("errorTextEmpty", true);
+                       template.set("returnPage", returnPage);
                }
+
        }
 
        //
index de1196b..ca9171b 100644 (file)
@@ -8,6 +8,7 @@
 
        <form method="post">
                <input type="hidden" name="formPassword" value="<% formPassword|html>" />
+               <input type="hidden" name="returnPage" value="<% returnPage|html>" />
 
                <div>
                        <label for="text"><%= Page.CreatePost.Label.Text|l10n|html></label>