SAP NetWeaver '04

com.sapportals.wcm.rendering.uicommand
Class AbstractUICommand

[contained in: com.sap.km.cm.ui.flex.par - km.shared.ui.flex.uicommand_api.jar]
java.lang.Object
  |
  +--com.sapportals.wcm.rendering.uicommand.AbstractUICommand
All Implemented Interfaces:
IExecCommand, IInitialScreenflowProvider, IUIBaseCommand, IUICommand

public abstract class AbstractUICommand
extends java.lang.Object
implements IUICommand, IInitialScreenflowProvider

This class can be used by IUICommands to reduce coding overhead and to take advantage of some convinience methods for resource bundle handling. It also holds some implementations for the ISelector interface. Copyright: Copyright 2004 SAP AG


Inner Class Summary
protected  class AbstractUICommand.ResourceNotFoundException
           
 
Field Summary
protected  int applicable
          The applicable flag set as default IExecCommand.APPLICABLE_UNKNOWN
protected  IResourceContext context
           
 java.lang.String layoutSetID
          Layout Set ID used for commands with selection
 AbstractProxyControl proxy
          command proxy
protected  IResource resource
          The resource for which the command operates its task
static RID ROOT_RID
           
 
Fields inherited from interface com.sapportals.wcm.rendering.base.IUIBaseCommand
ERR_MESSAGE_MISSING_CONFIG_ENTRY, ERR_MESSAGE_WRONG_METHOD_CALL, KEY_INPUT_CONTROL_TEXT, KEY_INPUT_CONTROL_TEXT_2, KEY_INPUT_CONTROL_TEXT_2_DEFAULT_TEXT, KEY_INPUT_CONTROL_TEXT_3, KEY_INPUT_CONTROL_TEXT_DEFAULT_TEXT, KEY_LABEL, KEY_MASS_EMBEDDED_COMMAND_TEXT, KEY_MASS_EMBEDDED_COMMANT_TOOLTIP, KEY_SINGLE_EMBEDDED_COMMAND_TEXT, KEY_SINGLE_EMBEDDED_COMMAND_TOOLTIP, KEY_TOOLTIP, LINE_BREAK, TEXT_KEYS, VALUE_EMPTY_STRING
 
Fields inherited from interface com.sapportals.wcm.rendering.uicommand.IExecCommand
APPLICABLE_FALSE, APPLICABLE_TRUE, APPLICABLE_UNKNOWN
 
Constructor Summary
AbstractUICommand()
          public constructor used by the UICommandFactory, when command is created for the first time
AbstractUICommand(java.lang.String keyLabel, java.lang.String keyTooltip)
          Allows to set keys for the label and the tooltip of the command.
 
Method Summary
 boolean allowUserInput()
           
protected  void createResource(IResourceContext context, RID rid)
          Creates an IResource from the given parameters and sets it as the member variable.
protected  IResource createResource(java.lang.String uri)
          Creates a IResource for a given uri
 com.sapportals.wdf.event.WdfEvent execute()
          This method will always throw a InvalidConfigurationException.
 com.sapportals.wdf.event.WdfEvent execute(com.sapportals.wdf.ControllerDynPage dynpage, boolean pushStack)
          Calls the execute method without parameters.
 java.lang.String getAlias()
          Gets the alias of the command
protected  java.lang.String getBundleString(java.lang.String key)
          Returns the translated text for the given key.
protected  java.lang.String getBundleString(java.lang.String key, java.lang.Object obj)
          Returns the translated text with the given variables included in the object.
protected  java.lang.String getBundleString(java.lang.String key, java.lang.Object[] obj)
          Returns the translated text with the given variables included in the object array.
protected  java.lang.String getBundleString(java.lang.String key, java.lang.Object obj1, java.lang.Object obj2)
          Returns the translated text with the given variables included in the two objects.
 java.lang.String getButtonLabel()
          Returns the text for the command when the command is rendered as button.
 com.sapportals.htmlb.Component getComponent()
          Returns a component for this command.
 java.util.Properties getConfigurationProperties()
          Returns the configproperties for this command.
 java.lang.String getDefaultInput(java.lang.String key)
          Used for commands with selection
 java.util.Map getInitialControlProperties()
          returns a map holding properties for the initial controls, where the control's classname acts as the key for the entry.
 java.lang.String[] getInitialControls()
          returns all controls that are to be rendered on the initial screen.
protected  java.lang.String getLabel()
          Returns the label text for the command.
 java.lang.String getLabel(java.lang.String key)
           
 java.lang.String getLayoutSetID()
          Returns the LayoutSet is which is configured in Configuration for Commands with Selection
 LinkAttributes getLinkAttributes()
          When the command selection generates an external link then this class should be implemented and a LinkAttributes
 java.lang.String getLinkLabel()
          Returns the text for the command when the command is rendered as link.
protected  java.lang.String getOTHDefinedURL(IResource res, IActionType actiontype)
          Returns the oth entry for a given IResource and a given IActionType
 java.util.Hashtable getParameters()
          Gets the command parameters.
 AbstractProxyControl getProxy()
          Gets the command proxy
 java.util.List getReplaceCommands()
          Gets the list of commands which will be ignored when the command is executable
 IResource getResource()
          Returns the resource the command operates on
protected  RID getStartUri()
          Returns the Start Uri value from proxy parameters
 java.lang.String getText(TextKey key)
          Generates the text for label & tooltip for the command according with the inputed IUIBaseCommand.TEXT_KEYS.
 java.lang.String getTextForSecondaryScreen(java.lang.String key)
          Gets the textForSecondaryScreen attribute of the AbstractUICommand object
protected  java.util.Properties getTextProperties()
          Returns the defined textproperties
protected  java.lang.String getTooltip()
          Returns the tooltip text for the command.
 com.sapportals.wcm.control.base.IMandatoryField[] getUserInputSpecifiers()
           
protected  void handleWrongConfiguration()
          Throws an InvalidConfigurationException that will be displayed on the screen and give further information what was invalid for the given configuration
protected  IUICommand initNewInstance(IUICommand command)
          Whenever a new instance of a command is needed, the newly created instance has to inherit all of the old instance's member variables, such as the alias, the resource bundle...
 boolean isApplicable()
          returns the information the command needs to carry out its task, when it is called through its execute method.
protected  boolean isMatchedPath(java.lang.String[] paths, java.lang.String resourcePath)
           
protected  boolean othAvailable(IResource res, IActionType actiontype)
          Checks if there are oth entries for a given IResource and a given IActionType
 boolean raisesEvent()
          Mostly, the command selection is followed another dialog which execute the command task.
protected  IResource resolveLink()
          Returns either the current resource, or the target of the current resource, if the current resource is an internal link
 void setAlias(java.lang.String alias)
          Sets the alias of command
 void setConfigurationProperties(java.util.Properties properties)
          Allows to set a free list of key-value pairs to be used by this command.
 void setLabelBundleKey(java.lang.String groupLabel)
          Currently not implemented.
 void setLayoutSetID(java.lang.String layoutSetID)
          Sets the LayoutSet is which is configured in Configuration for Commands with Selection
 void setParameters(java.util.Hashtable parameters)
          Sets parameters for the command.
 void setProxy(AbstractProxyControl proxy)
          Sets the proxy for the command
 void setReplaceCommands(java.util.List replaceCommandsList)
          Set the list of commands which will be ignored when the command is executable
 void setResource(IResource resource)
          Sets the resource the command shall operate on
 void setResourceBundle(ResourceBundles bundleFile)
          Sets the resourcebundle for this command
 void setResourceContext(IResourceContext context)
          Sets the IResourceContext
 void setScreenflow(com.sapportals.wdf.element.PaneElement startPane, com.sapportals.wdf.ControllerDynPage dynpage)
          do nothing, as no screenflow is defined here
 void setTextProperties(java.util.Properties properties)
          Copies the values of known keys from the given properties-object into its own list.
 void setTooltipBundleKey(java.lang.String groupTooltip)
          Currently not implemented.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sapportals.wcm.rendering.uicommand.IUICommand
getNewInstance
 
Methods inherited from interface com.sapportals.wcm.rendering.uicommand.IExecCommand
getTargetParameters, isExecutable, setTargetParameters
 

Field Detail

ROOT_RID

public static RID ROOT_RID

resource

protected IResource resource
The resource for which the command operates its task

applicable

protected int applicable
The applicable flag set as default IExecCommand.APPLICABLE_UNKNOWN

context

protected IResourceContext context

layoutSetID

public java.lang.String layoutSetID
Layout Set ID used for commands with selection

proxy

public AbstractProxyControl proxy
command proxy
Constructor Detail

AbstractUICommand

public AbstractUICommand()
public constructor used by the UICommandFactory, when command is created for the first time

AbstractUICommand

public AbstractUICommand(java.lang.String keyLabel,
                         java.lang.String keyTooltip)
Allows to set keys for the label and the tooltip of the command. It does not check, if the resource bundle holds entries for these keys.
Parameters:
keyLabel - the labelkey for the resourcebundle of the command, it is only set if it is not null
keyTooltip - the tooltipkey for the resourcebundle of the command, it is only set if it is not null
Method Detail

setResource

public void setResource(IResource resource)
Sets the resource the command shall operate on
Specified by:
setResource in interface IUIBaseCommand
Parameters:
resource - resource the command shall operate on. Must not be null

getResource

public IResource getResource()
Returns the resource the command operates on
Specified by:
getResource in interface IUICommand
Returns:
the resource the command operates on, can be null.

getTooltip

protected java.lang.String getTooltip()
Returns the tooltip text for the command. If no entry in the specified resource bundle is found, the class searches in its own static default resource bundle. If none can be found there, the alias-attribute of the class is returned.
Returns:
a tooltip for this command

getLabel

protected java.lang.String getLabel()
Returns the label text for the command. If no entry in the specified resource bundle is found, the class searches in its own static default resource bundle. If none can be found there, the alias-attribute of the class is returned.
Returns:
a label for this command

getText

public java.lang.String getText(TextKey key)
Generates the text for label & tooltip for the command according with the inputed IUIBaseCommand.TEXT_KEYS. For TextKey.LABEL it returns the command label text. For TextKey.TOOLTIP it returns the command tooltip text. For TextKey.LINK_LABEL it returns the command label when the command is rendered as link. If no special label is whished then it should return the same as for the TextKey.LABEL. For TextKey.BUTTON_LABEL it returns the command label when the command is rendered as button. If no special label is whished then it should return the same as for the TextKey.LABEL
Specified by:
getText in interface IUIBaseCommand
Following copied from interface: com.sapportals.wcm.rendering.base.IUIBaseCommand
Parameters:
key - the input TextKey
Returns:
The text value

setTextProperties

public void setTextProperties(java.util.Properties properties)
Copies the values of known keys from the given properties-object into its own list.
Specified by:
setTextProperties in interface IUICommand
Parameters:
properties - should hold key-value pairs with keys defined in IUIBaseCommand.TEXT_KEYS . Other key-value pairs will not be used.

getTextProperties

protected java.util.Properties getTextProperties()
Returns the defined textproperties
Returns:
the key-value pairs holding keys for the resourcebundle entries with texts for this command. Does not return null, but may return an empty Properties-object.

setResourceBundle

public void setResourceBundle(ResourceBundles bundleFile)
Sets the resourcebundle for this command
Specified by:
setResourceBundle in interface IUIBaseCommand
Parameters:
bundleFile - the bundle the command uses to retrieve its texts.

setLabelBundleKey

public void setLabelBundleKey(java.lang.String groupLabel)
Currently not implemented.
Specified by:
setLabelBundleKey in interface IUIBaseCommand
Parameters:
groupLabel - The new labelBundleKey value

setTooltipBundleKey

public void setTooltipBundleKey(java.lang.String groupTooltip)
Currently not implemented.
Specified by:
setTooltipBundleKey in interface IUIBaseCommand
Parameters:
groupTooltip - The new tooltipBundleKey value

setConfigurationProperties

public void setConfigurationProperties(java.util.Properties properties)
Allows to set a free list of key-value pairs to be used by this command. This
Specified by:
setConfigurationProperties in interface IUIBaseCommand
Parameters:
properties - free properties bag to be used by a command.

getConfigurationProperties

public java.util.Properties getConfigurationProperties()
Returns the configproperties for this command.
Specified by:
getConfigurationProperties in interface IUIBaseCommand
Returns:
the properties set for this command, e.g. in the configuration. Does not return null, but may return an empty properties-object.

getComponent

public com.sapportals.htmlb.Component getComponent()
Returns a component for this command. This could be used to display this command on the screen.
Specified by:
getComponent in interface IUIBaseCommand
Returns:
a component to display. Currently returns null;

createResource

protected void createResource(IResourceContext context,
                              RID rid)
                       throws WcmException
Creates an IResource from the given parameters and sets it as the member variable.
Parameters:
context - the current context of the session
rid - the identifier of the resource to create
Throws:
WcmException - if the resource could not be created.

raisesEvent

public boolean raisesEvent()
Mostly, the command selection is followed another dialog which execute the command task. If the command selection is followed by opening an external link then this method should be implemented by the command and it should return false. It should be implemented by the command class for the second type.
Specified by:
raisesEvent in interface IExecCommand
Following copied from interface: com.sapportals.wcm.rendering.uicommand.IExecCommand
Returns:
true, if the command raises an Event, false , if not

initNewInstance

protected final IUICommand initNewInstance(IUICommand command)
Whenever a new instance of a command is needed, the newly created instance has to inherit all of the old instance's member variables, such as the alias, the resource bundle... To aid with this, the implementing class can implement its getNewInstancemethod like this public getNewInstance() { return this.initNewInstance(new MyCommand()); } this abstract class' method will copy all of the member-attributes. Comparable to the deep-clone approach.
Parameters:
command - Description of the param
Returns:
Description of the Return Value

getLinkAttributes

public LinkAttributes getLinkAttributes()
When the command selection generates an external link then this class should be implemented and a LinkAttributes
Specified by:
getLinkAttributes in interface IExecCommand
Returns:
The linkAttributes value

setProxy

public void setProxy(AbstractProxyControl proxy)
Sets the proxy for the command
Specified by:
setProxy in interface IUIBaseCommand
Parameters:
proxy - The new proxy value

getProxy

public AbstractProxyControl getProxy()
Gets the command proxy

getTextForSecondaryScreen

public java.lang.String getTextForSecondaryScreen(java.lang.String key)
Gets the textForSecondaryScreen attribute of the AbstractUICommand object
Parameters:
key - Description of the param
Returns:
The textForSecondaryScreen value

getLabel

public java.lang.String getLabel(java.lang.String key)

getDefaultInput

public java.lang.String getDefaultInput(java.lang.String key)
Used for commands with selection

allowUserInput

public boolean allowUserInput()

getUserInputSpecifiers

public com.sapportals.wcm.control.base.IMandatoryField[] getUserInputSpecifiers()

getLayoutSetID

public java.lang.String getLayoutSetID()
Returns the LayoutSet is which is configured in Configuration for Commands with Selection
Returns:
The layoutSetID value

setLayoutSetID

public void setLayoutSetID(java.lang.String layoutSetID)
Sets the LayoutSet is which is configured in Configuration for Commands with Selection
Parameters:
layoutSetID - The new layoutSetID value

getAlias

public java.lang.String getAlias()
Gets the alias of the command
Specified by:
getAlias in interface IExecCommand
Returns:
The alias value

setAlias

public void setAlias(java.lang.String alias)
Sets the alias of command
Specified by:
setAlias in interface IExecCommand
Parameters:
alias - The new alias value

execute

public com.sapportals.wdf.event.WdfEvent execute()
                                          throws com.sapportals.wdf.WdfException
This method will always throw a InvalidConfigurationException. Either, the implementing class has not overwritten
Specified by:
execute in interface IUICommand
Returns:
Description of the Return Value
Throws:
WdfException - Exception raised in failure situation

execute

public com.sapportals.wdf.event.WdfEvent execute(com.sapportals.wdf.ControllerDynPage dynpage,
                                                 boolean pushStack)
                                          throws com.sapportals.wdf.WdfException
Calls the execute method without parameters.
Specified by:
execute in interface IUICommand
Parameters:
dynpage - - not used
pushStack - - not used
Returns:
Description of the Return Value
Throws:
WdfException - Exception raised in failure situation

setResourceContext

public void setResourceContext(IResourceContext context)
Sets the IResourceContext
Specified by:
setResourceContext in interface IUIBaseCommand
Parameters:
context - The new resourceContext value

getBundleString

protected java.lang.String getBundleString(java.lang.String key,
                                           java.lang.Object[] obj)
Returns the translated text with the given variables included in the object array. If the key cannot be found in the specified resource bundle, the class will check for it in its static default bundle. If it cannot be found here, an error message is logged and the alias of the implementing class is returned instead.
Parameters:
key - the key of the text to return - must not be null
obj - the variables to fill the place holders in the resource bundle, can be null
Returns:
The bundleString value
Throws:
java.util.MissingResourceException - if the IResourceContext is not set for the command

getBundleString

protected java.lang.String getBundleString(java.lang.String key)
Returns the translated text for the given key. If the key cannot be found in the specified resource bundle, the class will check for it in its static default bundle. If it cannot be found here, an error message is logged and the alias of the implementing class is returned instead.
Parameters:
key - the key of the text to return - must not be null
Returns:
The bundleString value
Throws:
java.util.MissingResourceException - if the IResourceContext is not set for the command

getBundleString

protected java.lang.String getBundleString(java.lang.String key,
                                           java.lang.Object obj)
Returns the translated text with the given variables included in the object. If the key cannot be found in the specified resource bundle, the class will check for it in its static default bundle. If it cannot be found here, an error message is logged and the alias of the implementing class is returned instead.
Parameters:
key - the key of the text to return - must not be null
obj - the variable to fill the place holder in the resource bundle, can be null
Returns:
The bundleString value
Throws:
java.util.MissingResourceException - if the IResourceContext is not set for the command

getBundleString

protected java.lang.String getBundleString(java.lang.String key,
                                           java.lang.Object obj1,
                                           java.lang.Object obj2)
Returns the translated text with the given variables included in the two objects. If the key cannot be found in the specified resource bundle, the class will check for it in its static default bundle. If it cannot be found here, an error message is logged and the alias of the implementing class is returned instead.
Parameters:
key - the key of the text to return - must not be null
obj1 - the variable to fill the first place holder in the resource bundle, can be null
obj2 - the variable to fill the second place holder in the resource bundle, can be null *
Returns:
The bundleString value
Throws:
java.util.MissingResourceException - if the IResourceContext is not set for the command

handleWrongConfiguration

protected void handleWrongConfiguration()
                                 throws com.sapportals.wcm.control.base.InvalidConfigurationException
Throws an InvalidConfigurationException that will be displayed on the screen and give further information what was invalid for the given configuration
Throws:
InvalidConfigurationException - Exception raised in failure situation

getReplaceCommands

public java.util.List getReplaceCommands()
Gets the list of commands which will be ignored when the command is executable
Specified by:
getReplaceCommands in interface IUIBaseCommand
Returns:
The replaceCommands value

setReplaceCommands

public void setReplaceCommands(java.util.List replaceCommandsList)
Set the list of commands which will be ignored when the command is executable
Specified by:
setReplaceCommands in interface IUIBaseCommand
Parameters:
replaceCommandsList - The new replaceCommands value

isApplicable

public boolean isApplicable()
returns the information the command needs to carry out its task, when it is called through its execute method. See the setTargetParameters method for details. The String[] must not contain any null values
Specified by:
isApplicable in interface IExecCommand
Returns:
The targetParameters value
Throws:
WcmException - Exception raised in failure situation

getStartUri

protected RID getStartUri()
Returns the Start Uri value from proxy parameters
Returns:
The start uri value

getLinkLabel

public java.lang.String getLinkLabel()
Returns the text for the command when the command is rendered as link. For this is looking for TextKey.LABEL key. If is founded then creates a new key using the "_l" suffix and then is looking in resource bundle for that key. if the key does not exists then it returns the text according with TextKey.LABEL key.
Specified by:
getLinkLabel in interface IUICommand
Following copied from interface: com.sapportals.wcm.rendering.uicommand.IUICommand
Returns:
the label to put on the link that leads to this Command

getButtonLabel

public java.lang.String getButtonLabel()
Returns the text for the command when the command is rendered as button. For this is looking for TextKey.LABEL key. If is founded then creates a new key using the "_b" suffix and then is looking in resource bundle for that key. If the key does not exists then getLinkLabel() method is called.
Specified by:
getButtonLabel in interface IUICommand
Following copied from interface: com.sapportals.wcm.rendering.uicommand.IUICommand
Returns:
the label to put on the button that leads to this Command

isMatchedPath

protected boolean isMatchedPath(java.lang.String[] paths,
                                java.lang.String resourcePath)

othAvailable

protected boolean othAvailable(IResource res,
                               IActionType actiontype)
Checks if there are oth entries for a given IResource and a given IActionType

getOTHDefinedURL

protected java.lang.String getOTHDefinedURL(IResource res,
                                            IActionType actiontype)
Returns the oth entry for a given IResource and a given IActionType

setParameters

public void setParameters(java.util.Hashtable parameters)
Sets parameters for the command. Each parameters should have an unique key and one or more values. If the parameter is null, it will not be used to overwrite the existing hashtable.
Specified by:
setParameters in interface IUIBaseCommand
Parameters:
parameters - The new parameters value

getParameters

public java.util.Hashtable getParameters()
Gets the command parameters. Might return an empty Hashtable, but never null.
Specified by:
getParameters in interface IUIBaseCommand
Returns:
The parameters value

getInitialControls

public java.lang.String[] getInitialControls()
Description copied from interface: IInitialScreenflowProvider
returns all controls that are to be rendered on the initial screen. The first control in the list is displayed on top of the pane. Must not be null, but can be of length 0
Specified by:
getInitialControls in interface IInitialScreenflowProvider

setScreenflow

public void setScreenflow(com.sapportals.wdf.element.PaneElement startPane,
                          com.sapportals.wdf.ControllerDynPage dynpage)
                   throws com.sapportals.wdf.WdfException
do nothing, as no screenflow is defined here
Specified by:
setScreenflow in interface IInitialScreenflowProvider
Following copied from interface: com.sapportals.wcm.rendering.base.IInitialScreenflowProvider
Parameters:
startPane - - the pane were to add the NextScreenElements which trigger the move to the next panes, must not be null
dynpage - - the page which holds all defined screenflows, must not be null
Throws:
WdfException - if the Wd-Framework throws exceptions when adding the screenflow

getInitialControlProperties

public java.util.Map getInitialControlProperties()
Description copied from interface: IInitialScreenflowProvider
returns a map holding properties for the initial controls, where the control's classname acts as the key for the entry. Might return null.
Specified by:
getInitialControlProperties in interface IInitialScreenflowProvider

createResource

protected IResource createResource(java.lang.String uri)
                            throws ResourceException,
                                   WcmException
Creates a IResource for a given uri
Throws:
WcmException - is thrown when no resource is found
ResourceException - is thrown by the RepositoryFramework and not caught by this method

resolveLink

protected final IResource resolveLink()
                               throws ResourceException
Returns either the current resource, or the target of the current resource, if the current resource is an internal link
Returns:
the current resource as defined in getResource(). If this resource is an internal link: this.getResource().getLinkType().equals(LinkType.INTERNAL), the target of this resource is returned.
Throws:
ResourceException - is thrown by the RepositoryFramework and not caught by this method

SAP NetWeaver '04

Copyright © 2004 by SAP AG. All Rights Reserved.
SAP, R/3, mySAP, mySAP.com, xApps, xApp, SAP NetWeaver, and other SAP products and services mentioned herein as well as their respective logos are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world. All other product and service names mentioned are the trademarks of their respective companies. Data contained in this document serves informational purposes only. National product specifications may vary.

These materials are subject to change without notice. These materials are provided by SAP AG and its affiliated companies ("SAP Group") for informational purposes only, without representation or warranty of any kind, and SAP Group shall not be liable for errors or omissions with respect to the materials. The only warranties for SAP Group products and services are those that are set forth in the express warranty statements accompanying such products and services, if any. Nothing herein should be construed as constituting an additional warranty.