예제 #1
0
  private HtmlTag makeEditForm(
      String resource, boolean firstTimeForNewPage, String defaultNewPageContent) throws Exception {
    HtmlTag form = new HtmlTag("form");
    form.addAttribute("name", "f");
    form.addAttribute("action", resource);
    form.addAttribute("method", "post");
    form.add(HtmlUtil.makeInputTag("hidden", "responder", "saveData"));
    form.add(HtmlUtil.makeInputTag("hidden", SAVE_ID, String.valueOf(SaveRecorder.newIdNumber())));
    form.add(
        HtmlUtil.makeInputTag("hidden", TICKET_ID, String.valueOf((SaveRecorder.newTicket()))));
    if (request.hasInput("redirectToReferer") && request.hasHeader("Referer")) {
      String redirectUrl = request.getHeader("Referer").toString();
      int questionMarkIndex = redirectUrl.indexOf("?");
      if (questionMarkIndex > 0) redirectUrl = redirectUrl.substring(0, questionMarkIndex);
      redirectUrl += "?" + request.getInput("redirectAction").toString();
      form.add(HtmlUtil.makeInputTag("hidden", "redirect", redirectUrl));
    }

    form.add(createTextarea(firstTimeForNewPage, defaultNewPageContent));
    form.add(createButtons());
    form.add(
        "<br/>Hints:\n<ul>"
            + "<li>Use alt+s (Windows) or control+s (Mac OS X) to save your changes. Or, tab from the text area to the \"Save\" button!</li>\n"
            + "<li>Grab the lower-right corner of the text area to increase its size (works with some browsers).</li>\n"
            + "</ul>");

    TagGroup group = new TagGroup();
    group.add(form);

    return group;
  }
예제 #2
0
 private String makeRightColumn() throws Exception {
   HtmlTag form = HtmlUtil.makeFormTag("post", resource);
   form.add(HtmlUtil.makeInputTag("hidden", "responder", "saveData"));
   form.add(
       HtmlUtil.makeInputTag(
           "hidden", EditResponder.TIME_STAMP, String.valueOf(clock.currentClockTimeInMillis())));
   form.add(
       HtmlUtil.makeInputTag(
           "hidden", EditResponder.TICKET_ID, String.valueOf(SaveRecorder.newTicket())));
   HtmlTag title = HtmlUtil.makeDivTag("centered");
   title.use(
       "This page has been recently modified.  You may want to merge existing page content into your changes.");
   form.add(title);
   form.add(makeMergeNewDivTag());
   form.add(makeMergeOldDivTag());
   form.add(addHiddenAttributes());
   return form.html();
 }