Esempio n. 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;
  }
 public void init(FitNesseContext context, Request request) throws IOException {
   this.context = context;
   baseUrl = (String) request.getHeader("Host");
   rootPath = request.getResource();
   formatter = makeFormatter(request);
 }