com.sas.actionprovider
Class HttpAction

com.sas.actionprovider.HttpAction
All Implemented Interfaces:
ActionStatusKeysInterface, SupplementalPropertyKeysInterface, BaseEntityInterface, BaseEntityValueInterface, EntityKeyInterface, java.awt.event.ActionListener, java.lang.Cloneable, java.rmi.Remote, java.util.EventListener, javax.swing.Action
Direct Known Subclasses:
SelectorAction

public class HttpAction

The HttpAction class is the base class for all actions acquired from the HttpActionProvider.

A basic understanding of the ActionProvider Framework, of which this class is a part, is recommended before attempting to use this class.


Actions are objects that encapsulate everything needed to:


Typically, a Command object associated with the Action contains the logic for actually performing the operation.

When multiple Actions of the same actionType ( e.g. a DRILL_DOWN_ACTION in an OLAPTableView ) appear in different areas of a Component, they all share the same Command instance. This is possible because the APF can apply certain Action attributes to the command during the command execution phase. Often these attributes are specific area-dependent values such as a row and/or column index.

Action attributes that are applied to the command are COMMAND-type attributes that are designated as such via a property of the AttributeDescriptorInterface that is associated with the attribute.

There are 5 properties of the AttributeDescriptorInterface that are pertinent in the APF:

  1. COMMAND: When true, these are Action attributes that the APF will apply to the command during the Action's execution phase.
  2. DYNAMIC: When true, the values of these Action attributes are generated by the APF support class during the Action acquisition phase.
  3. CUSTOM: When true, this type of attribute does not have a name that is explicitly defined or known by the APF support class like conventional DYNAMIC attributes but is one for which a value can be generated given some support class specific rule. For example, a table support class may expect that attributes of this type have a name corresponding to a column name and may then set the attribute's value to the data value for that column.
  4. visible When true, the attributeName/attributeValue become a key/value pair on the query string of the url generated for the Action. Otherwise, the pair is stored on the HttpActionProvider.
  5. EXTERNAL When true and visible is also true, the APF will include the attributeName and attributeValue on the request but will not apply the attribute to the command during the Action's execution phase().

The visible property is a standard, not supplemental, property and is accessed differently than the others:

action.getAttributeDescriptor("someAttributeName").setVisible(false);
boolean visible = action.getAttributeDescriptor("someAttributeName").isVisible();


Refer to the individually documented fields of the supplemental properties for examples demonstrating their accessibility methods. The fields also document the default values for these properties which may vary according to the type of attribute.

  1. Class-Based: Attributes defined by the Action class.
  2. Instance-Based: Attributes that are not defined by the Action class. Instead, they are attributes that are added dynamically to the Action instance.


Visit the AppDev Studio Developer's Site to access step-by-step examples, white papers and additional usage information at http://support.sas.com/rnd/appdev/.

Note: A snapshot of the AppDev Studio Developers Site is installed on your local Web server when you install AppDev Studio. To access the site from webAF, select Help -> Developer Site .

Since:
3.0
See Also:
HttpActionProvider

Field Summary
 
Fields inherited from interface com.sas.swing.util.Action
ALIGNMENT_CENTER, ALIGNMENT_LEADING, ALIGNMENT_LEFT, ALIGNMENT_RIGHT, ALIGNMENT_TRAILING, ALTERNATE_TEXT, COMMAND_CLASS, DISABLED_IMAGE_KEY, GROUP_NAME, IMAGE_KEY, LABEL, LARGE_DISABLED_ICON, LARGE_DISABLED_ICON_NAME, LARGE_ICON, LARGE_ICON_NAME, LONG_DISABLED_DESCRIPTION, LONG_NAME, MNEMONIC_INDEX, ROLLOVER_ICON_NAME, ROLLOVER_IMAGE_KEY, SHORT_DISABLED_DESCRIPTION, SMALL_DISABLED_ICON, SMALL_DISABLED_ICON_NAME, SMALL_ICON_NAME, STYLE_MAP, TARGET, TEXT_ALIGNMENT, TYPE, TYPE_BOOLEAN, TYPE_NORMAL, URL
 
Fields inherited from interface com.sas.actionprovider.ActionStatusKeysInterface
AREA_DISABLED, DISABLED, ENABLED, IS_CURRENT_STATE_DISABLED, MODEL_MEMBER_DISABLED, MODEL_STATE_DISABLED, MODEL_TYPE_DISABLED, UNSUPPORTED, VIEWER_DISABLED
 
Fields inherited from interface com.sas.actionprovider.SupplementalPropertyKeysInterface
COMMAND, CUSTOM, DYNAMIC, ENCODE, EXTERNAL
 
Constructor Summary
HttpAction()
          Default constructor
HttpAction(DynamicAttributeCommandInterface command)
          Command Constructor
 
Method Summary
 java.lang.String getCmdId()
          Returns the CMDID that uniquely identifies and references the command and, if applicable, its set of stored attributes on the HttpActionProvider.
 java.lang.String getURLBase()
          Returns the base of this Action's URL.
 com.sas.util.SimpleTemplate getURLTemplate()
          Returns the URLTemplate used in generating the action's URL.
 boolean isEscapeDynamicAttributeValues()
          Returns the boolean indicating whether the following characters in this action's dynamic attribute values need to be escaped when converted to url query string parameters.
 boolean isExternal()
          Returns the boolean indicating whether the HttpActionProvider that generates this Action will also be responsible for executing the Action's command.
 boolean isLink()
          Returning the boolean indicating whether this Action is expected to have its URL attribute set.
 void setCmdId(java.lang.String cmdId)
          Sets the CMDID that uniquely identifies and references the command and, if applicable, its set of stored attributes on the HttpActionProvider.
 void setEscapedDynamicAttributeValues(boolean escape)
          Sets the boolean indicating whether the following characters in this action's dynamic attribute values need to be escaped when converted to url query string parameters.
 void setExternal(boolean external)
          Sets the boolean indicating whether the HttpActionProvider that generates this Action will also be responsible for executing the Action's command.
 void setLink(boolean link)
          Sets the boolean indicating whether this Action is expected to have its URL attribute set.
 void setURLBase(java.lang.String URLBase)
          Sets the base of this Action's URL.
 void setURLTemplate(com.sas.util.SimpleTemplate URLTemplate)
          Sets the URLTemplate that may be used to generate this Action's URL attribute.
 
Methods inherited from class com.sas.actionprovider.BaseAction
actionPerformed, addPropertyChangeListener, applyCommandAttributes, clone, executeCommand, fireEvent, getActionStrategy, getActionType, getAttributeDescriptor, getAttributeDescriptors, getCommand, getReturnStatus, getValue, isCustom, performAction, putValue, removePropertyChangeListener, setActionStrategy, setActionType, setAttribute, setCommand, setCustom, setReturnStatus
 
Methods inherited from class com.sas.entities.BaseEntity
containsAttributeNamed, equals, equals, getAttribute, getAttribute, getAttributeCount, getAttributes, getEntityKey, getPropertyDescriptors, getStringAttribute, listAttributeNames, removeAllAttributes, sameEntity, setAttribute, setAttributes, setEntityKey, toString
 

Constructor Detail

HttpAction

public HttpAction()
Default constructor


HttpAction

public HttpAction(DynamicAttributeCommandInterface command)
Command Constructor

Parameters:
command - The command that contains to the logic to perform this action.
Method Detail

isExternal

public boolean isExternal()
Returns the boolean indicating whether the HttpActionProvider that generates this Action will also be responsible for executing the Action's command.

Default value is false.

Returns:
the boolean indicating whether the Action is an external type.
See Also:
setExternal(boolean)

setExternal

public void setExternal(boolean external)
Sets the boolean indicating whether the HttpActionProvider that generates this Action will also be responsible for executing the Action's command.

Parameters:
external - The Action's external attribute value.
See Also:
isExternal()

getCmdId

public java.lang.String getCmdId()
Returns the CMDID that uniquely identifies and references the command and, if applicable, its set of stored attributes on the HttpActionProvider.

Set by the HttpActionProvider.

Returns:
the Action's cmdId.
See Also:
setCmdId(java.lang.String), HttpActionProvider.CMDID

setCmdId

public void setCmdId(java.lang.String cmdId)
Sets the CMDID that uniquely identifies and references the command and, if applicable, its set of stored attributes on the HttpActionProvider.

Set by the HttpActionProvider.

Parameters:
the - Action's cmdId.
See Also:
getCmdId(), HttpActionProvider.CMDID

getURLTemplate

public com.sas.util.SimpleTemplate getURLTemplate()
Returns the URLTemplate used in generating the action's URL.

Returns:
the URLTemplate to generate the action's URL.
See Also:
setURLTemplate(com.sas.util.SimpleTemplate)

setURLTemplate

public void setURLTemplate(com.sas.util.SimpleTemplate URLTemplate)

Sets the URLTemplate that may be used to generate this Action's URL attribute.

URL generation is influenced by a number of factors. Here is a list of all such factors in order of decreasing precedence.

  1. The Action's URLBase attribute
  2. The Action's URLTemplate attribute
  3. The URLTemplate attribute of any viewer that implements the URLTemplateViewInterface
  4. The HttpActionProvider's controllerURL attribute
  5. The URI of the viewer's current request

To have a URL that calls a javascript function of the form:

        "function functionName(cmdId,actionProviderName,dynamicAttributes)"
 

You would have a template with the following pattern:

        "javascript: void(functionName('%CMDID','%APNAME','%DYNAMICATTRS'));"
 

The resulting URL would look like this:

        "javascript: void(functionName('54','AP1','AP1_foo=0&AP1_bar=13'));"
 

HttpActionProvider.CMDID, HttpActionProvider.APNAME and HttpActionProvider.DYNAMICATTRS are reserved keys that the URL generation routines look for in the template's pattern. CMDID and APNAME will be substituted with the value of the Action's cmdId attribute and the name of the ActionProvider, respectively.

If DYNAMICATTRS is found in the template, then that key will be substituted with a concatenated String consisting of all the name/value pairs of all the Action's remaining visible, instance-based attributes.

The URL generation routines will also attempt to match other pattern keys to all ( even type-based ) Action attributes. If a match occurs, then the method substitutes that attribute's value for that key.

If the Action attribute is a visible instance-based attribute, then the template should also include the PARMPREFIX reserved key because the javascript routine will need to prepend the attribute name with this prefix when submitting it on the request.

Visible instance-based attributes that have specific matches in the template are not included in the concatenated String of DYNAMICATTRS.

For example, the following template pattern:

        "javascript: void(functionName('%CMDID','%APNAME','%foo', %DYNAMICATTRS'));"
 

would result in the following:

        href="javascript: void(functionName('54','AP1','0','AP1_bar=13'));"
 

Templates containing "javascript:" may causes certain side effects. See setEscapedDynamicAttributeValues().

Parameters:
URLTemplate - The template to use in generating the action's URL.
See Also:
getURLTemplate(), setEscapedDynamicAttributeValues(boolean), setURLBase(java.lang.String), setURLTemplate(com.sas.util.SimpleTemplate), URLTemplateViewInterface.setURLTemplate(com.sas.util.SimpleTemplate), HttpActionProvider.setControllerURL(java.lang.String), HttpActionProviderViewInterface.setRequest(javax.servlet.http.HttpServletRequest)

getURLBase

public java.lang.String getURLBase()
Returns the base of this Action's URL.

Returns:
the base of this Action's URL.
See Also:
setURLBase(java.lang.String)

setURLBase

public void setURLBase(java.lang.String URLBase)
Sets the base of this Action's URL.

This value takes precedence over any of the other factor that influences the generation of this Action's URL. The following is a list of those other factors in order of decreasing precedence.

  1. The Action's URLBase attribute
  2. The Action's URLTemplate attribute
  3. The URLTemplate attribute of any viewer that implements the URLTemplateViewInterface
  4. The HttpActionProvider's controllerURL attribute
  5. The URI of the viewer's current request

Parameters:
URLBase - The base of this Action's URL.
See Also:
getURLBase(), setURLBase(java.lang.String), setURLTemplate(com.sas.util.SimpleTemplate), URLTemplateViewInterface.setURLTemplate(com.sas.util.SimpleTemplate), HttpActionProvider.setControllerURL(java.lang.String), HttpActionProviderViewInterface.setRequest(javax.servlet.http.HttpServletRequest)

isLink

public boolean isLink()
Returning the boolean indicating whether this Action is expected to have its URL attribute set.

Used for Actions that are needed to display some label or image but are not meant to provide any interactive capability.

Returns:
the boolean indicating whether this Action is expected to have its URL attribute set.
See Also:
setLink(boolean)

setLink

public void setLink(boolean link)
Sets the boolean indicating whether this Action is expected to have its URL attribute set.

Used for Actions that are needed to display some label or image but are not meant to provide any interactive capability.

The default value of this attribute is true.

Parameters:
link - The boolean indicating whether this Action is expected to have its URL attribute set.
See Also:
isLink()

isEscapeDynamicAttributeValues

public boolean isEscapeDynamicAttributeValues()
Returns the boolean indicating whether the following characters in this action's dynamic attribute values need to be escaped when converted to url query string parameters.

Typically, escaping these characters is not needed as all values are encoded which sufficiently eliminates any parsing problems for the client.

However, when the attribute value is passed as part of an argument to a javascript call that is associated with an html tag's "href" attribute, the values are un-encoded prior to that javascript call being made and, consequently, can cause problems with mismatched quotes.

The default for this attribute is false, but it automatically gets set to true if the URLTemplate attribute is set with a pattern containing "javascript:".

Returns:
the boolean indicating whether embedded backslashes, single quotes and double quotes in this action's dynamic attribute values need to be escaped when converted to url query string parameters.
See Also:
setEscapedDynamicAttributeValues(boolean)

setEscapedDynamicAttributeValues

public void setEscapedDynamicAttributeValues(boolean escape)
Sets the boolean indicating whether the following characters in this action's dynamic attribute values need to be escaped when converted to url query string parameters.

Typically, escaping these characters is not needed as all values are encoded which sufficiently eliminates any parsing problems for the client.

However, when the attribute value is passed as part of an argument to a javascript call that is associated with an html tag's "href" attribute, the values are un-encoded prior to that javascript call being made and, consequently, can cause problems with mismatched quotes.

The default for this attribute is false, but it automatically gets set to true if the URLTemplate attribute is set with a pattern containing "javascript:".

Parameters:
escape - the boolean indicating whether embedded backslashes, single quotes and double quotes in this action's dynamic attribute values need to be escaped when converted to url query string parameters.
See Also:
isEscapeDynamicAttributeValues()



Copyright © 2009 SAS Institute Inc. All Rights Reserved.