|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.click.control.AbstractControl net.sf.click.control.AbstractLink
Provides a Abstract Link control: <a href=""></a>.
See also the W3C HTML reference: A Links
ActionLink
,
Submit
,
Serialized FormField Summary | |
protected boolean |
disabled
The Field disabled value. |
protected String |
imageSrc
The image src path attribute. |
protected String |
label
The link display label. |
protected Map |
parameters
The link parameters map. |
protected int |
tabindex
The link 'tabindex' attribute. |
protected String |
title
The link title attribute, which acts as a tooltip help message. |
Fields inherited from class net.sf.click.control.AbstractControl |
actionListener, attributes, listener, listenerMethod, messages, name, parent, styles |
Fields inherited from interface net.sf.click.Control |
CONTROL_MESSAGES |
Constructor Summary | |
AbstractLink()
Create an AbstractLink with no name defined. |
|
AbstractLink(String name)
Create an AbstractLink for the given name. |
Method Summary | |
abstract String |
getHref()
Return the AbstractLink anchor <a> tag href attribute. |
String |
getHtmlImports()
This method returns null. |
String |
getId()
Return the "id" attribute value if defined, or null otherwise. |
String |
getImageSrc()
Return the image src path attribute. |
String |
getLabel()
Return the label for the AbstractLink. |
String |
getParameter(String name)
Return the link request parameter value for the given name, or null if the parameter value does not exist. |
Map |
getParameters()
Return the AbstractLink parameters Map. |
int |
getTabIndex()
Return the link "tabindex" attribute value. |
String |
getTag()
Return the links html tag: a. |
String |
getTitle()
Return the 'title' attribute, or null if not defined. |
boolean |
hasParameters()
Return true if the AbstractLink has parameters or false otherwise. |
boolean |
isDisabled()
Return true if the AbstractLink is a disabled. |
void |
render(HtmlStringBuffer buffer)
Render the HTML representation of the anchor link. |
void |
setDisabled(boolean disabled)
Set the disabled flag. |
void |
setImageSrc(String src)
Set the image src path attribute. |
void |
setLabel(String label)
Set the label for the ActionLink. |
void |
setParameter(String name,
String value)
Set the link parameter with the given parameter name and value. |
void |
setTabIndex(int tabindex)
Set the link "tabindex" attribute value. |
void |
setTitle(String value)
Set the 'title' attribute tooltip message. |
Methods inherited from class net.sf.click.control.AbstractControl |
addStyleClass, appendAttributes, getActionListener, getAttribute, getAttributes, getContext, getControlSizeEst, getMessage, getMessage, getMessage, getMessages, getName, getPage, getParent, getStyle, getStyles, hasAttribute, hasAttributes, hasStyles, onDeploy, onDestroy, onInit, onProcess, onRender, registerActionEvent, removeStyleClass, renderTagBegin, renderTagEnd, setActionListener, setAttribute, setId, setListener, setName, setParent, setStyle, toString |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected boolean disabled
protected String imageSrc
AbstractControl.toString()
method.
If the image src value is prefixed with '/' then the request context path
will be prefixed to the src value when rendered by the control.
protected String label
protected Map parameters
protected int tabindex
protected String title
Constructor Detail |
public AbstractLink(String name)
name
- the page link name
IllegalArgumentException
- if the name is nullpublic AbstractLink()
Method Detail |
public String getTag()
getTag
in class AbstractControl
AbstractControl.getTag()
public boolean isDisabled()
public void setDisabled(boolean disabled)
disabled
- the disabled flagpublic abstract String getHref()
public String getHtmlImports()
getHtmlImports
in interface Control
getHtmlImports
in class AbstractControl
Control.getHtmlImports()
public String getImageSrc()
AbstractControl.toString()
method, and the label will
not be rendered.
If the src value is prefixed with '/' then the request context path will
be prefixed to the src value when rendered by the control.
public void setImageSrc(String src)
AbstractControl.toString()
method, and the label will not be rendered.
src
- the image src path attributepublic String getId()
getId
in interface Control
getId
in class AbstractControl
Control.getId()
public String getLabel()
getName() + ".label"If not found then the message will be looked up in the /click-control.properties file using the same key. If a value still cannot be found then the ActinLink name will be converted into a label using the method:
ClickUtils.toLabel(String)
For examle given a OrderPage with the properties file
OrderPage.properties:
checkout.label=Checkout checkout.title=Proceed to CheckoutThe page ActionLink code:
public class OrderPage extends Page { ActionLink checkoutLink = new ActionLink("checkout"); .. }Will render the AbstractLink label and title properties as:
<a href=".." title="Proceed to Checkout">Checkout</a>When a label value is not set, or defined in any properties files, then its value will be created from the Fields name. For example given the ActionLink code:
ActionLink nameField = new ActionLink("deleteItem");Will render the ActionLink label as:
<a href="..">Delete Item</a>
Note the ActionLink label can include raw HTML to render other elements.
For example the configured label:
edit.label=<img src="images/edit.png" title="Edit Item"/>Will render the ActionLink label as:
<a href=".."><img src="images/edit.png" title="Edit Item"/></a>
public void setLabel(String label)
label
- the label for the ActionLinkgetLabel()
public String getParameter(String name)
name
- the name of request parameter
public void setParameter(String name, String value)
AbstractControl.toString()
method.
For example given the ActionLink:
PageLink editLink = new PageLink("editLink", EditCustomer.class); editLink.setLabel("Edit Customer"); editLink.setParameter("customerId", customerId);And the page template:
$editLink
Will render the HTML as:
<a href="/mycorp/edit-customer.htm?customerId=13490">Edit Customer</a>
name
- the attribute namevalue
- the attribute value
IllegalArgumentException
- if name parameter is nullpublic Map getParameters()
public boolean hasParameters()
public int getTabIndex()
public void setTabIndex(int tabindex)
tabindex
- the link "tabindex" attribute valuepublic String getTitle()
getName() + ".title"If not found then the message will be looked up in the /click-control.properties file using the same key. For examle given a ItemsPage with the properties file ItemPage.properties:
edit.label=Edit edit.title=Edit ItemThe page ActionLink code:
public class ItemsPage extends Page { ActionLink editLink = new ActionLink("edit"); .. }Will render the ActionLink label and title properties as:
<a href=".." title="Edit Item">Edit</a>
public void setTitle(String value)
value
- the 'title' attribute tooltip messagegetTitle()
public void render(HtmlStringBuffer buffer)
AbstractControl.setAttribute(String, String)
for an
example.
If the image src is defined then a <img/> element will
rendered inside the anchor link instead of the label property.
This method invokes the abstract getHref()
method.
render
in interface Control
render
in class AbstractControl
buffer
- the specified buffer to render the control's output toAbstractControl.toString()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |