コード例 #1
0
  /**
   * Encode the HTML code of the button.
   *
   * @param context the current FacesContext
   * @param attrs the attribute list
   * @throws IOException thrown if something's wrong with the ResponseWriter
   */
  public void encodeHTML(FacesContext context, Map<String, Object> attrs) throws IOException {
    ResponseWriter rw = context.getResponseWriter();

    Object value = attrs.get(VALUE);
    String style = asString(attrs.get(STYLE));

    rw.startElement(BUTTON, this);
    rw.writeAttribute(ID, getClientId(context), ID);
    rw.writeAttribute(NAME, getClientId(context), NAME);
    rw.writeAttribute(TYPE, BUTTON, null);
    if (style != null) {
      rw.writeAttribute(STYLE, style, STYLE);
    }
    rw.writeAttribute(CLASS, getStyleClasses(attrs), CLASS);

    Tooltip.generateTooltip(context, attrs, rw);

    final String clickHandler = encodeClick(context, attrs);
    if (null != clickHandler && clickHandler.length() > 0) {
      rw.writeAttribute(CLICK, clickHandler, null);
    }
    String d = asString(attrs.get(DISMISS));
    if (d != null) {
      rw.writeAttribute(DATA_DISMISS, d, null);
    }
    boolean disabled = (toBool(attrs.get(DISABLED)));
    if (disabled) {
      rw.writeAttribute(DISABLED, DISABLED, null);
    }

    // Encode attributes (HTML 4 pass-through + DHTML)
    renderPassThruAttributes(context, this, ALLBUTTON_ATTRS);

    String icon = asString(attrs.get(ICON));
    String faicon = asString(attrs.get(ICONAWESOME));
    boolean fa = false; // flag to indicate wether the selected icon set is Font Awesome or not.
    if (faicon != null) {
      icon = faicon;
      fa = true;
    }
    if (icon != null) {
      Object ialign = attrs.get(ICON_ALIGN); // Default Left
      // !//boolean white=null!=attrs.get(LOOK);
      if (ialign != null && ialign.equals(RIGHT)) {
        rw.writeText(value + SP, null);
        R.encodeIcon(rw, this, icon, fa);
        // !//R.encodeIcon(rw, this, icon, white);
      } else {
        R.encodeIcon(rw, this, icon, fa);
        // !//R.encodeIcon(rw, this, icon, white);
        rw.writeText(SP + value, null);
      }

    } else {
      rw.writeText(value, null);
    }

    rw.endElement(BUTTON);
  }
コード例 #2
0
  /**
   * Renders the button. <br>
   * General layout of the generated HTML code:<br>
   * &lt;button class="btn btn-large" href="#"%gt;&lt;i class="icon-star"&gt;&lt;/i&gt;
   * Star&lt;/button&gt;
   *
   * @param context the current FacesContext
   * @throws IOException thrown if something's wrong with the ResponseWriter
   */
  @Override
  public void encodeEnd(FacesContext context) throws IOException {
    if (!isRendered()) {
      return;
    }

    encodeHTML(context, getAttributes());
    Tooltip.activateTooltips(context, getAttributes(), this);
  }
コード例 #3
0
 /**
  * This methods generates the HTML code of the current b:buttonToolbar. <code>encodeBegin</code>
  * generates the start of the component. After the, the JSF framework calls <code>encodeChildren()
  * </code> to generate the HTML code between the beginning and the end of the component. For
  * instance, in the case of a panel component the content of the panel is generated by <code>
  * encodeChildren()</code>. After that, <code>encodeEnd()</code> is called to generate the rest of
  * the HTML code.
  *
  * @param context the FacesContext.
  * @param component the current b:buttonToolbar.
  * @throws IOException thrown if something goes wrong when writing the HTML code.
  */
 @Override
 public void encodeEnd(FacesContext context, UIComponent component) throws IOException {
   if (!component.isRendered()) {
     return;
   }
   ButtonToolbar buttonToolbar = (ButtonToolbar) component;
   ResponseWriter rw = context.getResponseWriter();
   String clientId = buttonToolbar.getClientId();
   rw.endElement("buttonToolbar");
   Tooltip.activateTooltips(fc, c.getAttributes(), c);
 }
コード例 #4
0
  /**
   * This methods generates the HTML code of the current b:buttonToolbar. <code>encodeBegin</code>
   * generates the start of the component. After the, the JSF framework calls <code>encodeChildren()
   * </code> to generate the HTML code between the beginning and the end of the component. For
   * instance, in the case of a panel component the content of the panel is generated by <code>
   * encodeChildren()</code>. After that, <code>encodeEnd()</code> is called to generate the rest of
   * the HTML code.
   *
   * @param context the FacesContext.
   * @param component the current b:buttonToolbar.
   * @throws IOException thrown if something goes wrong when writing the HTML code.
   */
  @Override
  public void encodeBegin(FacesContext context, UIComponent component) throws IOException {
    if (!component.isRendered()) {
      return;
    }
    ButtonToolbar buttonToolbar = (ButtonToolbar) component;
    ResponseWriter rw = context.getResponseWriter();
    String clientId = buttonToolbar.getClientId();

    // put custom code here
    // Simple demo widget that simply renders every attribute value
    rw.startElement("buttonToolbar", buttonToolbar);
    Tooltip.generateTooltip(context, buttonToolbar, rw);

    rw.writeAttribute("binding", buttonToolbar.getBinding(), "binding");
    rw.writeAttribute("id", buttonToolbar.getId(), "id");
    rw.writeAttribute("rendered", String.valueOf(buttonToolbar.isRendered()), "rendered");
    rw.writeAttribute("tooltip", buttonToolbar.getTooltip(), "tooltip");
    rw.writeAttribute("tooltipDelay", buttonToolbar.getTooltipDelay(), "tooltipDelay");
    rw.writeAttribute("tooltipDelayHide", buttonToolbar.getTooltipDelayHide(), "tooltipDelayHide");
    rw.writeAttribute("tooltipDelayShow", buttonToolbar.getTooltipDelayShow(), "tooltipDelayShow");
    rw.writeAttribute("tooltipPosition", buttonToolbar.getTooltipPosition(), "tooltipPosition");
    rw.writeText("Dummy content of b:buttonToolbar", null);
  }
コード例 #5
0
 public CommandButton() {
   setRendererType(DEFAULT_RENDERER); // this component renders itself
   AddResourcesListener.addResourceToHeadButAfterJQuery(C.BSF_LIBRARY, "jq/jquery.js");
   Tooltip.addResourceFile();
 }
コード例 #6
0
 public InputText() {
   setRendererType("net.bootsfaces.component.InputTextRenderer");
   Tooltip.addResourceFile();
 }
コード例 #7
0
 public PanelGrid() {
   Tooltip.addResourceFile();
   setRendererType(DEFAULT_RENDERER);
 }