Click Framework  History | Log In     View a printable version of the current page. Get help!  
Issue Details (XML | Word)

Key: CLK-392
Type: New Feature New Feature
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Malcolm Edgar
Reporter: Demetrios Kyriakis
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Click

PageLinkButton Control.

Created: 10/Jun/08 10:57 PM   Updated: 11/Jun/08 09:46 PM
Component/s: extras
Affects Version/s: 1.5 M1 , 1.4.2
Fix Version/s: 1.5 M2


 Description  « Hide
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()
                + "';";
     }
}
-------------------------------

 All   Comments   Change History      Sort Order:
Ahmed Mohombe [11/Jun/08 09:46 PM]
This new control is in SVN now (but only for click 1.5.2 because the 1.4.x is a bugfix only branch).

Also I added to the javadocs the "advantages" of this control over other approaches (taken form the mentioned discussion thread).