private final Template orgas = new Template(ViewOrgPage.class.getResource("ViewOrgs.templ"));
+ private final Template mainTempl = new Template(ViewOrgPage.class.getResource("EditOrg.templ"));
+
public static final String DEFAULT_PATH = "/orga";
public ViewOrgPage() {
@Override
public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException {
try {
- Form.getForm(req, CreateOrgForm.class).submit(resp.getWriter(), req);
+ if (req.getParameter("affiliate") != null) {
+ AffiliationForm form = Form.getForm(req, AffiliationForm.class);
+ form.submit(resp.getWriter(), req);
+ resp.sendRedirect(DEFAULT_PATH + "/" + form.getOrganisation().getId());
+ } else {
+ Form.getForm(req, CreateOrgForm.class).submit(resp.getWriter(), req);
+ }
} catch (GigiApiException e) {
e.format(resp.getWriter(), getLanguage(req));
}
if (count >= orgas.length)
return false;
Organisation org = orgas[count++];
- System.out.println(org.getId());
vars.put("id", Integer.toString(org.getId()));
vars.put("name", org.getName());
vars.put("country", org.getState());
resp.sendError(404);
return;
}
- new CreateOrgForm(req, o).output(out, lang, new HashMap<String, Object>());
- out.println(lang.getTranslation("WARNING: updating the data will revoke all issued certificates."));
+ HashMap<String, Object> vars = new HashMap<>();
+ vars.put("editForm", new CreateOrgForm(req, o));
+ vars.put("affForm", new AffiliationForm(req, o));
+ mainTempl.output(out, lang, vars);
}
}