org.apache.struts2.components
Class Anchor

java.lang.Object
  extended by org.apache.struts2.components.Component
      extended by org.apache.struts2.components.UIBean
          extended by org.apache.struts2.components.ClosingUIBean
              extended by org.apache.struts2.components.RemoteCallUIBean
                  extended by org.apache.struts2.components.Anchor

public class Anchor
extends RemoteCallUIBean

A tag that creates a HTML <a href='' /> that when clicked calls a URL remote XMLHttpRequest call via the dojo framework. The result from the URL is executed as JavaScript. If a "listenTopics" is supplied, it will publish a 'click' message to that topic when the result is returned.

Examples

 
 <s:a id="link1" theme="ajax" href="/DoIt.action" errorText="An error ocurred" showErrorTransportText="true">
     <img border="none" src="<%=request.getContextPath()%>/images/delete.gif"/>
     <s:param name="id" value="1"/>
 </s:a>
 
 

Results in

 
 <a dojoType="BindAnchor" evalResult="true" id="link1" href="/DoIt.action?id=1" errorHtml="An error ocurred"
 showTransportError="true"></a>
 
 

Here is an example that uses the postInvokeJS. This example is in altSyntax=true:

 
 <s:a id="test" theme="ajax" href="/simpeResult.action" preInvokeJS="confirm(\'You sure\')">
        A
 </s:a>
 
 


Field Summary
static java.lang.String COMPONENT_NAME
           
protected  java.lang.String notifyTopics
           
static java.lang.String OPEN_TEMPLATE
           
protected  java.lang.String preInvokeJS
           
static java.lang.String TEMPLATE
           
 
Fields inherited from class org.apache.struts2.components.RemoteCallUIBean
afterLoading, errorText, href, showErrorTransportText
 
Fields inherited from class org.apache.struts2.components.UIBean
accesskey, cssClass, cssStyle, disabled, label, labelPosition, name, onblur, onchange, onclick, ondblclick, onfocus, onkeydown, onkeypress, onkeyup, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup, onselect, request, required, requiredposition, response, tabindex, template, templateDir, templateSuffix, theme, title, tooltip, tooltipConfig, value
 
Fields inherited from class org.apache.struts2.components.Component
COMPONENT_STACK, id, parameters, stack
 
Constructor Summary
Anchor(com.opensymphony.xwork2.util.ValueStack stack, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
           
 
Method Summary
 void evaluateExtraParams()
           
 java.lang.String getDefaultOpenTemplate()
           
protected  java.lang.String getDefaultTemplate()
          A contract that requires each concrete UI Tag to specify which template should be used as a default.
 void setId(java.lang.String id)
          The id to assign the component
 void setNotifyTopics(java.lang.String notifyTopics)
          Topic names to post an event to after the remote call has been made
 void setPreInvokeJS(java.lang.String preInvokeJS)
          A javascript snippet that will be invoked prior to the execution of the target href.
 
Methods inherited from class org.apache.struts2.components.RemoteCallUIBean
setAfterLoading, setErrorText, setHref, setShowErrorTransportText, setTheme
 
Methods inherited from class org.apache.struts2.components.ClosingUIBean
setOpenTemplate, start
 
Methods inherited from class org.apache.struts2.components.UIBean
addFormParameter, buildTemplateName, enableAncestorFormCustomOnsubmit, end, escape, evaluateNameValue, evaluateParams, getTemplate, getTemplateDir, getTheme, getTooltipConfig, getValueClassType, mergeTemplate, populateComponentHtmlId, setAccesskey, setCssClass, setCssStyle, setDisabled, setLabel, setLabelposition, setName, setOnblur, setOnchange, setOnclick, setOndblclick, setOnfocus, setOnkeydown, setOnkeypress, setOnkeyup, setOnmousedown, setOnmousemove, setOnmouseout, setOnmouseover, setOnmouseup, setOnselect, setRequired, setRequiredposition, setTabindex, setTemplate, setTemplateDir, setTitle, setTooltip, setTooltipConfig, setValue
 
Methods inherited from class org.apache.struts2.components.Component
addAllParameters, addParameter, altSyntax, copyParams, determineActionURL, determineNamespace, end, fieldError, findAncestor, findString, findString, findValue, findValue, findValue, getComponentStack, getId, getParameters, getStack, popComponentStack, toString, usesBody
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OPEN_TEMPLATE

public static final java.lang.String OPEN_TEMPLATE
See Also:
Constant Field Values

TEMPLATE

public static final java.lang.String TEMPLATE
See Also:
Constant Field Values

COMPONENT_NAME

public static final java.lang.String COMPONENT_NAME

notifyTopics

protected java.lang.String notifyTopics

preInvokeJS

protected java.lang.String preInvokeJS
Constructor Detail

Anchor

public Anchor(com.opensymphony.xwork2.util.ValueStack stack,
              javax.servlet.http.HttpServletRequest request,
              javax.servlet.http.HttpServletResponse response)
Method Detail

getDefaultOpenTemplate

public java.lang.String getDefaultOpenTemplate()
Specified by:
getDefaultOpenTemplate in class ClosingUIBean

getDefaultTemplate

protected java.lang.String getDefaultTemplate()
Description copied from class: UIBean
A contract that requires each concrete UI Tag to specify which template should be used as a default. For example, the CheckboxTab might return "checkbox.vm" while the RadioTag might return "radio.vm". This value not begin with a '/' unless you intend to make the path absolute rather than relative to the current theme.

Specified by:
getDefaultTemplate in class UIBean
Returns:
The name of the template to be used as the default.

evaluateExtraParams

public void evaluateExtraParams()
Overrides:
evaluateExtraParams in class RemoteCallUIBean

setId

public void setId(java.lang.String id)
The id to assign the component

Overrides:
setId in class Component

setNotifyTopics

public void setNotifyTopics(java.lang.String notifyTopics)
Topic names to post an event to after the remote call has been made


setPreInvokeJS

public void setPreInvokeJS(java.lang.String preInvokeJS)
A javascript snippet that will be invoked prior to the execution of the target href. If provided must return true or false. True indicates to continue executing target, false says do not execute link target. Possible uses are for confirm dialogs.



Copyright © 2000-2006 Apache Software Foundation. All Rights Reserved.