com.sas.servlet.util
Class ComponentPropertyManager

com.sas.servlet.util.ComponentPropertyManager

public class ComponentPropertyManager

The ComponentPropertyManager is responsible for holding global properties which are application specific such as locations for images, javascript, and templates. It also handles the changing and setting of themes. Themes will override the default global properties used by the components. Changes to properties made on a specific component will override the themes and default global properties on the ComponentPropertyManager.
Only one ComponentPropertyManager is created per session per web application. The same ComponentPropertyManager is used throughout that session.
If you want to override the defaults for the ComponentPropertyManager, then you can place a file named "sas_ComponentProperties.config" into the web-inf directory of your web application. The property names in the config file should be: ImageLocation StyleLocation JavaScriptLocation TemplateLocation TemplateURLLocation DynamicButtonRootName OutputCharacterEncoding InputCharacterEncoding ContextMenuLaunchEvent For example, you can change the ImageLocation by using: ImageLocation=foo/ or ImageLocation=http://myserver/myapp/foo. This would change the ImageLocation directory to be "foo/" or "http://myserver/myapp/foo", respectively. A good use of the sas_ComponentProperties.config file is to set the ImageLocation, StyleLocation, and TemplateURLLocation to be the fully qualified path to an HTTP server hosting those resources. This will increase performance since those static resources will not have to be served by the application server. The order of precedence that the ComponentPropertyManager uses is as follows: 1. Calling the setters on the ComponentPropertyManager instance itself overrides all. The set value will be used. 2. If the above value was null, check and use a SAS Theme resource if available (only available for ImageLocation, StyleLocation, and TemplateURLLocation). 3. If the above value was null, check if the sas_ComponentProperties.config was present and use any non-null values as the new default values. 4. Otherwise, use the default locations with the determined path prefixed to the location.


Field Summary
protected  java.lang.String absolutePath
           
protected  java.lang.String contextPath
           
protected static java.lang.String DEFAULT_CONTEXT_MENU_LAUNCH_EVENT
           
protected static java.lang.String DEFAULT_DOCTYPE
           
protected static java.lang.String DEFAULT_INPUT_CHARACTER_ENCODING
           
protected static java.lang.String DEFAULT_OUTPUT_CHARACTER_ENCODING
           
static java.lang.String DEFAULT_STYLE_SHEET
           
protected  GraphStyle defaultGraphStyle
           
protected  GraphStyle graphStyle
           
protected static java.lang.String META_REFRESH_INT
           
 
Constructor Summary
protected ComponentPropertyManager()
           
 
Method Summary
 java.lang.String getAbsolutePath()
           
 java.lang.String getContextMenuLaunchEvent(TransformationInterface tBean)
           
protected  java.lang.String getContextPath()
          The path to be prefixed to the default locations to create an absolute path.
 java.lang.String getDynamicButtonRootName()
          Gets the dynamicButtonRootName property.
 GraphStyle getGraphStyle()
          Returns the default graphStyle based the the current theme.
 java.lang.String getImageLocation()
          The path location where all images for a web application can be found.
 java.lang.String getInputCharacterEncoding()
          Gets the inputCharacterEncoding property.
static ComponentPropertyManager getInstance(javax.servlet.http.HttpServletRequest request)
          Returns the appropriate ComponentPropertyManager for the given request.
 java.lang.String getJavaScriptLocation()
          The path location where all javascript (.js) files for a web application can be found.
 java.lang.String getOutputCharacterEncoding()
          Gets the outputCharacterEncoding property.
protected  com.sas.preferences.SASProfileInterface getSASProfile()
          Deprecated.  
 java.lang.String getStyleLocation()
          The path location where all style sheets (.css files) for a web application can be found.
 java.lang.String getStyleSheetLinks(java.util.List l)
          Return the cascading style sheet link html tags to be used in a page.
 java.util.List getStyleSheetList()
          Gets the java.util.List of cascading style sheets to be written out.
 java.lang.String getTemplateLocation()
          The path location where all template files for a web application can be found.
 java.lang.String getTemplateURLLocation()
          The path location where all template files for a web application can be found.
 boolean isAutoComplete()
          Returns true if auto complete is turned on the forms and input elements, false otherwise.
 void setAbsolutePath(java.lang.String absolutePath)
           
 void setAutoComplete(boolean value)
          Sets the state of the autoComplete on FORM tbeans as well as input elements with type of TEXT & PASSWORD.
 void setContextMenuLaunchEvent(TransformationInterface tBean, java.lang.String contextMenuLaunchEvent)
          Associates contextMenuLaunchEvent with the viewer.
protected  void setContextPath(java.lang.String requestingURI)
          The path to be prefixed to the default locations to create an absolute path.
 void setDynamicButtonRootName(java.lang.String root)
          Sets the dynamicButtonRootName property.
 void setGraphStyle(GraphStyle graphStyle)
          Sets the graphStyle used for this instance of the ComponentPropertyManager.
 void setImageLocation(java.lang.String location)
          Sets the path location where all images for a web application can be found.
 void setInputCharacterEncoding(java.lang.String characterEncoding)
          Sets the inputCharacterEncoding property.
 void setJavaScriptLocation(java.lang.String location)
          Sets the path location where all javascript (.js) files for a web application can be found.
 void setOutputCharacterEncoding(java.lang.String characterEncoding)
          Sets the outputCharacterEncoding property.
 void setSASProfile(com.sas.preferences.SASProfileInterface sasProfile)
          Deprecated.  
 void setStyleLocation(java.lang.String location)
          Sets the path location where all style sheets (.css files) for a web application can be found.
 void setStyleSheetList(java.util.List list)
          Sets the java.util.List of cascading style sheets to be written out.
 void setTemplateLocation(java.lang.String location)
          Sets the path location where all template files for a web application can be found.
 void setTemplateURLLocation(java.lang.String url)
          Sets the URL path location where all template files for a web application can be found.
 

Field Detail

DEFAULT_STYLE_SHEET

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

DEFAULT_INPUT_CHARACTER_ENCODING

protected static final java.lang.String DEFAULT_INPUT_CHARACTER_ENCODING
See Also:
Constant Field Values

DEFAULT_OUTPUT_CHARACTER_ENCODING

protected static final java.lang.String DEFAULT_OUTPUT_CHARACTER_ENCODING
See Also:
Constant Field Values

DEFAULT_CONTEXT_MENU_LAUNCH_EVENT

protected static final java.lang.String DEFAULT_CONTEXT_MENU_LAUNCH_EVENT
See Also:
Constant Field Values

DEFAULT_DOCTYPE

protected static final java.lang.String DEFAULT_DOCTYPE

META_REFRESH_INT

protected static final java.lang.String META_REFRESH_INT
See Also:
Constant Field Values

contextPath

protected java.lang.String contextPath

absolutePath

protected java.lang.String absolutePath

graphStyle

protected GraphStyle graphStyle

defaultGraphStyle

protected GraphStyle defaultGraphStyle
Constructor Detail

ComponentPropertyManager

protected ComponentPropertyManager()
Method Detail

getStyleSheetLinks

public java.lang.String getStyleSheetLinks(java.util.List l)
Return the cascading style sheet link html tags to be used in a page. This method will write out the link tags and create an href based on getStyleLocation() and getStyleSheetList(). The default String returned is:

Returns:
The style sheet html link tags

getInstance

public static ComponentPropertyManager getInstance(javax.servlet.http.HttpServletRequest request)
Returns the appropriate ComponentPropertyManager for the given request. If one does not already exist then a new ComponentPropertyManager is created and stored on the session object for the given request. The same ComponentPropertyManager will be used per session per web application.

Parameters:
request - The HttpServletRequest
Returns:
an instance of the ComponentPropertyManager

setGraphStyle

public void setGraphStyle(GraphStyle graphStyle)
Sets the graphStyle used for this instance of the ComponentPropertyManager.

Parameters:
graphStyle - the graph style.

getGraphStyle

public GraphStyle getGraphStyle()
Returns the default graphStyle based the the current theme. STYLE_OLAP is the default graph style.

Returns:
the graphStyle

getImageLocation

public java.lang.String getImageLocation()
The path location where all images for a web application can be found. If null, then the location returned will be the first non-null value of the following: 1. Theme location 2. sas_ComponentProperties.config location. 3. Default value, DEFAULT_IMAGE_LOCATION (context and path prefixed).

Returns:
the path location for all images

setImageLocation

public void setImageLocation(java.lang.String location)
Sets the path location where all images for a web application can be found.

Parameters:
location - the path location for all images

getStyleLocation

public java.lang.String getStyleLocation()
The path location where all style sheets (.css files) for a web application can be found. If null, then the location returned will be the first non-null value of the following: 1. Theme location 2. sas_ComponentProperties.config location. 3. Default value, DEFAULT_STYLE_LOCATION (context and path prefixed).

Returns:
the path location for all style sheets

setStyleLocation

public void setStyleLocation(java.lang.String location)
Sets the path location where all style sheets (.css files) for a web application can be found.

Parameters:
location - the path location for all style sheets

getJavaScriptLocation

public java.lang.String getJavaScriptLocation()
The path location where all javascript (.js) files for a web application can be found. If null, then the location returned will be the first non-null value of the following: 1. sas_ComponentProperties.config location. 2. Default value, DEFAULT_JAVASCRIPT_LOCATION (context and path prefixed).

Returns:
the path location for all javascript (.js) files

setJavaScriptLocation

public void setJavaScriptLocation(java.lang.String location)
Sets the path location where all javascript (.js) files for a web application can be found.

Parameters:
location - the path location for all javascript (.js) files

getTemplateLocation

public java.lang.String getTemplateLocation()
The path location where all template files for a web application can be found. If null, then the location returned will be the first non-null value of the following: 1. sas_ComponentProperties.config location. 2. Default value, DEFAULT_TEMPLATE_LOCATION.

Returns:
the path location for all template files

setTemplateLocation

public void setTemplateLocation(java.lang.String location)
Sets the path location where all template files for a web application can be found. This is the location based off the servlet context. Code that uses TemplateLocation uses javax.servlet.ServletContext.getResourceAsStream.

Parameters:
location - the path location for all template files
See Also:
setTemplateURLLocation(java.lang.String)

getDynamicButtonRootName

public java.lang.String getDynamicButtonRootName()
Gets the dynamicButtonRootName property. Some images (such as buttons) are actually multiple images combined to appear as one image. The dynamicButtonRootName is the root name for all images in a given group of images. In a group of images named: foo1.gif, foo2.gif...fooN.gif, the dynamicButtonRootName would be "foo". If null, then the location returned will be the first non-null value of the following: 1. sas_ComponentProperties.config name. 2. Default value, DEFAULT_DYNAMIC_BUTTON_ROOT_NAME.

Returns:
the root name for all images within a group of images

setDynamicButtonRootName

public void setDynamicButtonRootName(java.lang.String root)
Sets the dynamicButtonRootName property. Some images (such as buttons) are actually multiple images combined to appear as one image. The dynamicButtonRootName is the prefix name for all images in a given group of images. In a group of images named: foo1.gif, foo2.gif...fooN.gif, the dynamicButtonRootName would be "foo".

Parameters:
root - the root name for all images within a group of images

getInputCharacterEncoding

public java.lang.String getInputCharacterEncoding()
Gets the inputCharacterEncoding property.

Returns:
the character input encoding

setInputCharacterEncoding

public void setInputCharacterEncoding(java.lang.String characterEncoding)
Sets the inputCharacterEncoding property.

Parameters:
characterEncoding - the character input encoding.

getOutputCharacterEncoding

public java.lang.String getOutputCharacterEncoding()
Gets the outputCharacterEncoding property. This is the character encoding to use when setting the HttpServletResponse's character encoding. For example, when calling HttpServletResponse.setContentType() you should use the outputCharacterEncoding. If null, then the location returned will be the first non-null value of the following: 1. sas_ComponentProperties.config value. 2. Default value, DEFAULT_OUTPUT_CHARACTER_ENCODING.

Returns:
the character encoding to set on the HttpServletResponse

setOutputCharacterEncoding

public void setOutputCharacterEncoding(java.lang.String characterEncoding)
Sets the outputCharacterEncoding property. This is the character encoding to use when setting the HttpServletResponse's character encoding. For example, when calling HttpServletResponse.setContentType() you should use the outputCharacterEncoding.

Parameters:
characterEncoding - the character encoding to set on the HttpServletResponse

setStyleSheetList

public void setStyleSheetList(java.util.List list)
Sets the java.util.List of cascading style sheets to be written out. The default is to use the sasComponents.css only.

Parameters:
list - The list of style sheets

getStyleSheetList

public java.util.List getStyleSheetList()
Gets the java.util.List of cascading style sheets to be written out. The default is to use the sasComponents.css only.

Returns:
The List of cascading style sheets to be written out.

getTemplateURLLocation

public java.lang.String getTemplateURLLocation()
The path location where all template files for a web application can be found. If null, then the location returned will be the first non-null value of the following: 1. Theme location 2. sas_ComponentProperties.config location.

Returns:
The URL for the template location

setTemplateURLLocation

public void setTemplateURLLocation(java.lang.String url)
Sets the URL path location where all template files for a web application can be found. This should be used instead of setTemplateLocation if the templates are located in another web application or in a location that requires an absolute path to the template. Code that uses TemplateURLLocation does not use javax.servlet.ServletContext.getResourceAsStream.

Parameters:
url - The URL for the component template location
See Also:
setTemplateLocation(java.lang.String)

setContextPath

protected void setContextPath(java.lang.String requestingURI)
The path to be prefixed to the default locations to create an absolute path.

Parameters:
contextPath - The contextPath to set.

getContextPath

protected java.lang.String getContextPath()
The path to be prefixed to the default locations to create an absolute path.

Returns:
Returns the contextPath.

getSASProfile

protected com.sas.preferences.SASProfileInterface getSASProfile()
Deprecated. 

Get the SASProfile value. Used internally by the ComponentPropertyManager.

Returns:
Returns

setSASProfile

public void setSASProfile(com.sas.preferences.SASProfileInterface sasProfile)
Deprecated. 

Set internally if the SASProfile is present on the session. Used internally by the ComponentPropertyManager.

Parameters:
SASProfile - The SASProfile to set.

getAbsolutePath

public java.lang.String getAbsolutePath()
Returns:
Returns the absolutePath.

setAbsolutePath

public void setAbsolutePath(java.lang.String absolutePath)
Parameters:
absolutePath - The absolutePath to set.

setAutoComplete

public void setAutoComplete(boolean value)
Sets the state of the autoComplete on FORM tbeans as well as input elements with type of TEXT & PASSWORD.

Parameters:
value - the state of the forms and input elements

isAutoComplete

public boolean isAutoComplete()
Returns true if auto complete is turned on the forms and input elements, false otherwise.

Returns:
the state of the forms and input elements auto completion

setContextMenuLaunchEvent

public void setContextMenuLaunchEvent(TransformationInterface tBean,
                                      java.lang.String contextMenuLaunchEvent)
Associates contextMenuLaunchEvent with the viewer.

Parameters:
tBean -
contextMenuLaunchEvent -

getContextMenuLaunchEvent

public java.lang.String getContextMenuLaunchEvent(TransformationInterface tBean)
Parameters:
tBean -
Returns:
the conextMenuLaunchEvent associated with the viewer.



Copyright © 2009 SAS Institute Inc. All Rights Reserved.