Uploaded image for project: 'Click'
  1. Click
  2. CLK-392

PageLinkButton Control.

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.5 M1, 1.4.2
    • 1.5 M2
    • extras
    • None

    Description

      Please include in Click the PageLinkButton Control discussed in this thread:
      http://www.nabble.com/-Control-Wishlist--LinkButton.-td17274531.html

      The advantages of this new Control(over the actual solution for the needed use cases) are mentioned in the posts of the above thread, and the proposed implementation seems to work with click 1.4.2

      Thank you,

      Demetrios.

      P.S. Proposed implementation of PageLinkButton.java:
      -----------------------------------
      package net.sf.click.extras.control;

      import net.sf.click.control.PageLink;
      import net.sf.click.util.HtmlStringBuffer;

      /**

      • PageLink rendered as push button.
        *
        */
        public class PageLinkButton extends PageLink {
        public PageLinkButton(String name) { super(name); }

      public PageLinkButton(String name, Class targetPage)

      { super(name, targetPage); }

      public PageLinkButton(String name, String label, Class targetPage)

      { super(name, label, targetPage); }

      public PageLinkButton(Class targetPage)

      { super(targetPage); }

      public PageLinkButton() {
      }

      /**

      • Return a HTML rendered Button string. Note the button label is rendered
      • as the HTML "value" attribute.
        *
      • @see Object#toString()
        *
      • @return a HTML rendered Button string
        */
        public String toString() {
        HtmlStringBuffer buffer = new HtmlStringBuffer(40);

      buffer.elementStart("input");

      buffer.appendAttribute("type", "button");
      buffer.appendAttribute("name", getName());
      buffer.appendAttribute("id", getId());
      buffer.appendAttribute("value", getLabel());
      buffer.appendAttribute("title", getTitle());
      if (getTabIndex() > 0)

      { buffer.appendAttribute("tabindex", getTabIndex()); }

      String onClickAction = " onclick=\"" + getOnClick() + "\"";
      buffer.append(onClickAction);

      appendAttributes(buffer);

      if (isDisabled())

      { buffer.appendAttributeDisabled(); }

      buffer.elementEnd();

      return buffer.toString();
      }
      /**

      • Return the Button anchor <a> tag href attribute value.
        *
      • @return the Button anchor <a> tag HTML href attribute value
        */
        public String getOnClick() { return "javascript:document.location.href='" + getHref() + "';"; }

        }
        -------------------------------

      Attachments

        Activity

          People

            medgar Malcolm Edgar
            dkyriakis Demetrios Kyriakis
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: