]> WPIA git - gigi.git/blob - src/club/wpia/gigi/pages/ManagedFormPage.java
upd: use a link-redirector for all external links.
[gigi.git] / src / club / wpia / gigi / pages / ManagedFormPage.java
1 package club.wpia.gigi.pages;
2
3 import java.io.IOException;
4
5 import javax.servlet.http.HttpServletRequest;
6 import javax.servlet.http.HttpServletResponse;
7
8 import club.wpia.gigi.output.template.Form;
9
10 public abstract class ManagedFormPage extends Page {
11
12     Class<? extends Form> c;
13
14     public ManagedFormPage(String title, Class<? extends Form> t) {
15         super(title);
16         c = t;
17     }
18
19     @Override
20     public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
21         if (Form.printFormErrors(req, resp.getWriter())) {
22             Form form = Form.getForm(req, c);
23             form.output(resp.getWriter(), getLanguage(req), getDefaultVars(req));
24         }
25     }
26
27     @Override
28     public boolean beforePost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
29         return Form.getForm(req, c).submitExceptionProtected(req, resp);
30     }
31
32 }