コード例 #1
0
  /**
   * Description of the Method
   *
   * @param s Description of the Parameter
   * @return Description of the Return Value
   */
  protected Element makeInput(WebSession s) {
    Table t = new Table(0).setCellSpacing(0).setCellPadding(0).setBorder(0);
    TR row1 = new TR();
    TR row2 = new TR();
    row1.addElement(new TD(new StringElement(WebGoatI18N.get("Title") + ": ")));

    Input inputTitle = new Input(Input.TEXT, TITLE, "");
    row1.addElement(new TD(inputTitle));

    TD item1 = new TD();
    item1.setVAlign("TOP");
    item1.addElement(new StringElement(WebGoatI18N.get("Message") + ": "));
    row2.addElement(item1);

    TD item2 = new TD();
    TextArea ta = new TextArea(MESSAGE, 5, 60);
    item2.addElement(ta);
    row2.addElement(item2);
    t.addElement(row1);
    t.addElement(row2);

    Element b = ECSFactory.makeButton(WebGoatI18N.get("Submit"));
    ElementContainer ec = new ElementContainer();
    ec.addElement(t);
    ec.addElement(new P().addElement(b));

    return (ec);
  }
コード例 #2
0
ファイル: Button2Zero.java プロジェクト: webguitoolkit/wgt-ui
  /** output HTML for button */
  protected void endHTML(PrintWriter out) {
    Span span = new Span();
    Table table = new Table();
    TR top = new TR();
    TD topLeft = new TD();
    TD topCenter = new TD();
    TD topRight = new TD();
    TR middle = new TR();
    TD midLeft = new TD();
    TD midCenter = new TD();
    TD midRight = new TD();
    TR bottom = new TR();
    TD botLeft = new TD();
    TD botCenter = new TD();
    TD botRight = new TD();
    Span textContainer = new Span();
    org.apache.ecs.html.Button button = new org.apache.ecs.html.Button();
    boolean disabled = getContext().processBool(getId() + ".disabled");

    // build table
    table.addElement(top);
    top.addElement(topLeft);
    top.addElement(topCenter);
    top.addElement(topRight);

    table.addElement(middle);
    middle.addElement(midLeft);
    middle.addElement(midCenter);
    middle.addElement(midRight);

    table.addElement(bottom);
    bottom.addElement(botLeft);
    bottom.addElement(botCenter);
    bottom.addElement(botRight);

    // set pixels
    IMG spacer = new IMG("./images/wgt/1.gif");
    spacer.setWidth(1);
    spacer.setHeight(1);
    topLeft.addElement(new IMG("./images/wgt/1.gif"));
    topCenter.addElement(new IMG("./images/wgt/1.gif"));
    topRight.addElement(new IMG("./images/wgt/1.gif"));
    midLeft.addElement(new IMG("./images/wgt/1.gif"));
    midRight.addElement(new IMG("./images/wgt/1.gif"));
    botLeft.addElement(new IMG("./images/wgt/1.gif"));
    botCenter.addElement(new IMG("./images/wgt/1.gif"));
    botRight.addElement(new IMG("./images/wgt/1.gif"));

    // format table
    table.setCellPadding(0);
    table.setCellSpacing(0);
    table.setBorder(0);

    // set classes
    topLeft.setClass("btn_lt");
    topCenter.setClass("btn_ct");
    topRight.setClass("btn_rt");
    midLeft.setClass("btn_lm");
    midCenter.setClass("btn_cm");
    midRight.setClass("btn_rm");
    botLeft.setClass("btn_lb");
    botCenter.setClass("btn_cb");
    botRight.setClass("btn_rb");

    button.setClass("btn_btn");
    button.setID(getId() + "_btn");
    midCenter.addElement(button);
    textContainer.setID(id4Text());
    textContainer.setClass("btn_txt");

    if (StringUtils.isNotEmpty(getSrc())) {
      if (StringUtils.isEmpty(this.getLabel())) {
        button.setStyle(
            "width:"
                + iconWidth
                + "px;height:"
                + iconHeight
                + "px;background: transparent url("
                + getSrc()
                + ") no-repeat; background-position: center;");
      } else {
        button.setStyle("background: transparent url(" + getSrc() + ") no-repeat;");
      }
    }

    if (StringUtils.isNotEmpty(this.getLabel())) {
      if (StringUtils.isNotEmpty(getSrc()) && iconWidth > -1) {
        if (displayMode == DISPLAY_MODE_VERTICAL) {
          // image top
          String s = button.getAttribute("style");
          s =
              s
                  + "background-position: center top;padding-top:"
                  + String.valueOf(iconHeight)
                  + "px;";
          button.setStyle(s);
        } else {
          // image left
          textContainer.setStyle("padding-left: " + String.valueOf(iconWidth) + "px;");
        }
      }
      textContainer.addElement(this.getLabel());
      button.addElement(textContainer);
    }

    // this.getStyle().add("table-layout", "fixed");

    if (this.hasStyle()) {
      table.setStyle(this.getStyleAsString());
    }

    midCenter.setID(getId());
    // midCenter.setOnClick(JSUtil.jsFireEvent(getId(),
    //		ClientEvent.TYPE_ACTION)
    //		+ " return false;");
    button.setOnClick(JSUtil.jsFireEvent(getId(), ClientEvent.TYPE_ACTION) + " return false;");
    // action goes to onClick handler
    if (getConfirmMsg() != null) {
      button.setOnClick(
          JSUtil.jsConfirm(
              TextService.getString(getConfirmMsg()),
              JSUtil.jsFireEvent(getId(), ClientEvent.TYPE_ACTION)));
    } else {
      button.setOnClick(JSUtil.jsFireEvent(getId(), ClientEvent.TYPE_ACTION) + " return false;");
    }

    // table.output(out);
    span.addElement(table);
    span.setID(getId() + "_sspan");
    if (block && isVisible()) {
      span.setStyle("display:block;");
    }

    span.output(out);

    this.initJaveScript();
  }