html.render(new SiteLayoutWrapper(new TranslatorForm()));
}
public void post(HtmlCanvas html, HandlerResult result) throws IOException {
ContextMap session = RequestUtils.getSession(html);
boolean useTidy = "on".equals(RequestUtils.getParameter(html,"tidy"));
String handle = RequestUtils.getParameter(html,"handle");
if ("translate".equals(handle)) {
ByteArrayInputStream input = new ByteArrayInputStream(RequestUtils.getParameter(html,"html").getBytes());
HtmlToRenderSnakeTranslator translator = new HtmlToRenderSnakeTranslator();
try {
translator.translate(input,useTidy);
} catch (Exception ex) {
translator.errorMessage = ex.getMessage();
}
session.withString("java", translator.isSuccess() ? translator.toJavaSource() : translator.errorMessage);
session.withString("html", RequestUtils.getParameter(html,"html"));
}
if ("back".equals(handle)) {
session.withString("java", null);
}
if (useTidy) {
session.withString("tidy", "on");
} else {
session.withString("tidy", null);
}
result.redirectTo("translator.html");
}