|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.click.control.AbstractControl org.apache.click.control.AbstractLink
public abstract class 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<String,Object> |
parameters
The link parameters map. |
protected boolean |
renderLabelAndImage
Flag to set if both icon and text are rendered, default value is false. |
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 org.apache.click.control.AbstractControl |
---|
actionListener, attributes, behaviors, headElements, listener, listenerMethod, messages, name, parent, styles |
Fields inherited from interface org.apache.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 | |
---|---|
protected void |
bindRequestParameters(Context context)
This method binds the submitted request parameters to the link parameters. |
void |
bindRequestValue()
This method does nothing by default since AbstractLink does not bind to request values. |
void |
defineParameter(String name)
Defines a link parameter that will have its value bound to a matching request parameter. |
abstract String |
getHref()
Return the AbstractLink anchor <a> tag href attribute. |
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<String,Object> |
getParameters()
Return the AbstractLink parameters Map. |
String[] |
getParameterValues(String name)
Return the link request parameter values for the given name, or null if the parameter values does not exist. |
Object |
getState()
Return the link state. |
int |
getTabIndex()
Return the link "tabindex" attribute value. |
String |
getTag()
Return the link html tag: a. |
String |
getTitle()
Return the 'title' attribute, or null if not defined. |
boolean |
hasParameters()
Return true if the AbstractLink has parameters, false otherwise. |
boolean |
isAjaxTarget(Context context)
Returns true if this control is an AJAX target, false otherwise. |
boolean |
isDisabled()
Return true if the AbstractLink is a disabled. |
boolean |
isRenderLabelAndImage()
Returns true if both icon
and label are rendered,
false otherwise. |
void |
removeState(Context context)
Remove the link state from the session for the given request context. |
void |
render(HtmlStringBuffer buffer)
Render the HTML representation of the anchor link. |
protected void |
renderImgTag(HtmlStringBuffer buffer)
Render the Image tag to the buffer. |
protected void |
renderParameters(HtmlStringBuffer buffer,
Map<String,Object> parameters,
Context context)
Render the given link parameters to the buffer. |
void |
restoreState(Context context)
Restore the link state from the session for the given request context. |
void |
saveState(Context context)
Save the link state to the session for the given request context. |
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,
Object value)
Set the link parameter with the given parameter name and value. |
void |
setParameters(Map parameters)
Set the AbstractLink parameter map. |
void |
setParameterValues(String name,
Object[] values)
Set the link parameter with the given parameter name and values. |
void |
setRenderLabelAndImage(boolean renderLabelAndImage)
Sets whether both label and
icon are rendered for this
link. |
void |
setState(Object state)
Set the link state. |
void |
setTabIndex(int tabindex)
Set the link "tabindex" attribute value. |
void |
setTitle(String value)
Set the 'title' attribute tooltip message. |
Methods inherited from class org.apache.click.control.AbstractControl |
---|
addBehavior, addStyleClass, appendAttributes, dispatchActionEvent, getActionListener, getAttribute, getAttributes, getBehaviors, getContext, getControlSizeEst, getHeadElements, getHtmlImports, getMessage, getMessage, getMessages, getName, getPage, getParent, getStyle, getStyles, hasAttribute, hasAttributes, hasBehaviors, hasStyles, onDeploy, onDestroy, onInit, onProcess, onRender, removeBehavior, 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<String,Object> parameters
protected int tabindex
protected String title
protected boolean renderLabelAndImage
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 getImageSrc()
AbstractControl.toString()
method.
Note: the label will not be rendered in this case (default behavior),
unless the setRenderLabelAndImage(boolean)
flag is set to true.
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.
Note: the label will not be rendered in this case (default behavior),
unless the setRenderLabelAndImage(boolean)
flag is set to true.
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 ActionLink name will be converted into a label using the method:
ClickUtils.toLabel(String)
For example 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, Object 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 String[] getParameterValues(String name)
name
- the name of request parameter
public void setParameterValues(String name, Object[] values)
parameters
.
name
- the attribute namevalues
- the attribute values
IllegalArgumentException
- if name parameter is nullsetParameter(java.lang.String, java.lang.Object)
public Map<String,Object> getParameters()
public void setParameters(Map parameters)
parameters
- the link parameter mappublic void defineParameter(String name)
setParameter
implicitly defines a parameter as well.
Please note: parameters need only be defined for Ajax requests.
For non-Ajax requests, all incoming request parameters
are bound, whether they are defined or not. This behavior may change in a
future release.
Also note: link parameters are bound to request parameters
during the AbstractControl.onProcess()
event, so link parameters must be defined
in the Page constructor or onInit() event.
name
- the name of the parameter to definepublic 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 boolean isRenderLabelAndImage()
true
if both icon
and label
are rendered,
false
otherwise.
true
if both icon and text are rendered,
false
otherwisepublic void setRenderLabelAndImage(boolean renderLabelAndImage)
label
and
icon
are rendered for this
link.
renderLabelAndImage
- sets the rendering type of the link.public boolean isAjaxTarget(Context context)
AbstractControl
ID
is send as a request parameter.
isAjaxTarget
in interface Control
isAjaxTarget
in class AbstractControl
context
- the request context
public void bindRequestValue()
public Object getState()
getState
in interface Stateful
public void setState(Object state)
setState
in interface Stateful
state
- the link state to setpublic 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()
public void removeState(Context context)
context
- the request contextsaveState(org.apache.click.Context)
,
restoreState(org.apache.click.Context)
public void restoreState(Context context)
setState(java.lang.Object)
to set the
link restored state.
context
- the request contextsaveState(org.apache.click.Context)
,
removeState(org.apache.click.Context)
public void saveState(Context context)
getState()
to retrieve the link state
to save.
context
- the request contextrestoreState(org.apache.click.Context)
,
removeState(org.apache.click.Context)
protected void renderImgTag(HtmlStringBuffer buffer)
buffer
- the buffer to render the image tag toprotected void renderParameters(HtmlStringBuffer buffer, Map<String,Object> parameters, Context context)
ClickUtils.encodeUrl(java.lang.Object, org.apache.click.Context)
.
buffer
- the buffer to render the parameters toparameters
- the parameters to rendercontext
- the request contextprotected void bindRequestParameters(Context context)
context
- the request context
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |