com.cc.framework.ui.painter
Interface PainterContext

All Superinterfaces:
HttpContext, RequestContext
All Known Implementing Classes:
CellPainterContext, PainterContextImp, PainterContextWrapper

public interface PainterContext
extends RequestContext

This class encapsulates all the necessary objects for painting the control.

Since:
1.2
Version:
$Revision: 1.63 $
Author:
Harald Schulz

Method Summary
 java.lang.String attr(java.lang.Object raw)
          Converts a String to a valid HTML Attribute
 java.lang.String attr(java.lang.Object raw, boolean filter)
          Converts a String to a valid HTML Attribute
 java.lang.String attr(java.lang.Object raw, boolean filter, int maxlength)
          Converts a String to a valid HTML Attribute
 void close()
          After the painter context has been used it has to be closed.
 ActionPainter createActionPainter(ControlActionDef action)
          Creates an ActionPainter.
 ActionPainter createActionPainter(ControlActionDef action, java.lang.String actionName)
          Creates an ActionPainter.
 org.apache.ecs.html.IMG createImage(ImageModel image)
          Retrieves an image for the specified Id
 org.apache.ecs.html.IMG createImage(int size, java.lang.String resourceId)
          Retrieves an image for the specified Id
 org.apache.ecs.html.IMG createImage(java.lang.String resourceId)
          Retrieves an image for the specified Id
 org.apache.ecs.html.IMG createImage(java.lang.String resourceId, java.lang.Object param)
          Retrieves an image for the specified Id
 org.apache.ecs.html.Input createInput(ImageModel image)
          Retrieves an image for the specified Id
 org.apache.ecs.html.Input createInput(java.lang.String resourceId)
          Retrieves an image for the specified Id
 java.lang.String decorateURL(java.lang.String url)
          Decorates the URL with RequestDecorator settings and appends the JSESSIONID when URL-rewriting is enabled to track sessions Every URL has to be decorated this way!
 java.lang.String getAsString(Converter converter, java.lang.Object value)
          Uses a Bean Converter to convert the given object to a String representation.
 java.lang.Object getAttribute(java.lang.String key, boolean searchParent)
          Gets an Attribute from the Painter Context hierarchy
 java.awt.Color getAwtColor(java.lang.String resourceId)
          Retrieves an color for the specified Id
 Color getColor(java.lang.String resourceId)
          Retrieves an color for the specified Id
 Control getControl()
           
 java.lang.String getElementName()
          Retrieves the name of the HTML element.
 java.lang.String getFrameworkString(java.lang.String resourceId)
          Returns a framework string resource
 java.lang.String getFrameworkString(java.lang.String resourceId, java.lang.Object[] arguments)
          Returns a framework string resource
 ImageModel getImage(int size, java.lang.String resourceId)
          Retrieves an image for the specified Id
 ImageModel getImage(java.lang.String resourceId)
          Retrieves an image for the specified Id
 ImageModel getImage(java.lang.String resourceId, java.lang.Object param)
          Retrieves an image for the specified Id
 java.lang.String getImageSrc(int size, java.lang.String resourceId)
          Retrieves an image for the specified Id
 java.lang.String getImageSrc(java.lang.String resourceId)
          Retrieves an image for the specified Id
 java.lang.String getImageSrc(java.lang.String resourceId, java.lang.Object param)
          Retrieves an image for the specified Id
 java.util.Locale getLocale()
          Gets the Locale Setting for this Control
 javax.servlet.jsp.PageContext getPageContext()
          Gets the Page Context
 java.lang.String getResourceDir()
          Returns the base directory used for resource by the painter factory
 java.lang.String getSource(ImageModel image)
          Gets the localized resource name
 java.lang.String getSource(java.lang.String base, java.lang.String src)
          Returns the localized Image resource name
 java.lang.String getStringResource(java.lang.String stringOrKey)
          Returns a string resource
 java.lang.String getStyleId()
          Returns the Style Id of the control.
 boolean hasAttribute(java.lang.String key, boolean searchParent)
          Gets an Attribute from the Painter Context hierarchy
 java.lang.String html(java.lang.Object raw)
          Converts a String to an equivalent HTML-String
 java.lang.String html(java.lang.Object raw, boolean filter)
          Converts a String to an equivalent HTML-String
 java.lang.String html(java.lang.Object raw, boolean filter, int maxlength)
          Converts a String to an equivalent HTML-String
 boolean isDisplayOnly()
          This method checks if a control that is rendered within this painter context has to be "display only"
 boolean isRunAtClient()
          This Method checks if the control should run on the client
 java.lang.String localize(java.lang.String keyOrString)
          Localizes a string depending on the localization settings of the Painter context
 java.lang.String localize(java.lang.String keyOrString, java.util.Locale locale)
          Localizes a string depending on the localization settings of the Painter context
 java.lang.String localize(java.lang.String keyOrString, java.lang.Object[] arguments)
          Localizes a string depending on the localization settings of the Painter context
 java.lang.String localizeKey(java.lang.String resourceId, java.lang.Object[] arguments, boolean returnNull)
          Localizes a string depending on the localization settings of the Painter context.
 void open()
          The painter context has to be opened before it can be used.
 void popAttributes()
          Restores the attributes from the Stack all current attributes are lost
 void pushAttributes()
          Pushes the current attributes on a stack for later restore
 java.lang.Object removeAttribute(java.lang.String key)
          Removes an Attribute for this Painter
 java.lang.String removeHtml(java.lang.Object html)
          Removes all HTML formatting from the given HTML-String
 java.lang.String removeHtml(java.lang.Object html, boolean filter)
          Removes all HTML formatting from the given HTML-String depending on the filter setting
 void setAttribute(java.lang.String key, java.lang.Object value)
          Sets an Attribute for this Painter
 void setFactory(PainterFactory factory)
          Sets the painter factory
 boolean showComments()
          This method checks if HTML comments should be written to the output
 java.lang.String truncate(java.lang.Object obj, int maxlength)
          Truncates a given string to a maximum number of characters
 
Methods inherited from interface com.cc.framework.adapter.RequestContext
getNestedContext, getPrincipal
 
Methods inherited from interface com.cc.framework.http.HttpContext
getAttribute, getServletContext, request, response, session
 

Method Detail

open

public void open()
The painter context has to be opened before it can be used. It initializes some internal variables


close

public void close()
After the painter context has been used it has to be closed. This will remove some internal variables from the request


getElementName

public java.lang.String getElementName()
Retrieves the name of the HTML element. This could be a path name when the control is nested within another control

Returns:
The name to use for the name-attribute of a HTML element

setFactory

public void setFactory(PainterFactory factory)
Sets the painter factory

Parameters:
factory - Painter factory

getPageContext

public javax.servlet.jsp.PageContext getPageContext()
Gets the Page Context

Returns:
PageContext

getAsString

public java.lang.String getAsString(Converter converter,
                                    java.lang.Object value)
                             throws ConverterException
Uses a Bean Converter to convert the given object to a String representation.

Parameters:
converter - The converter to use or null to use a default Converter
value - The Bean to convert
Returns:
String or null
Throws:
ConverterException - Is thrown when a conversion exception occurs

decorateURL

public java.lang.String decorateURL(java.lang.String url)
Decorates the URL with RequestDecorator settings and appends the JSESSIONID when URL-rewriting is enabled to track sessions Every URL has to be decorated this way!

Parameters:
url - the URL to encode
Returns:
encoded URL

getResourceDir

public java.lang.String getResourceDir()
Returns the base directory used for resource by the painter factory

Returns:
The web resource directory

getStringResource

public java.lang.String getStringResource(java.lang.String stringOrKey)
Returns a string resource

Parameters:
stringOrKey - Id of the resource/key
Returns:
The value for the resource id

getFrameworkString

public java.lang.String getFrameworkString(java.lang.String resourceId)
Returns a framework string resource

Parameters:
resourceId - Id of the resource/key
Returns:
The value for the resource id

getFrameworkString

public java.lang.String getFrameworkString(java.lang.String resourceId,
                                           java.lang.Object[] arguments)
Returns a framework string resource

Parameters:
resourceId - Id of the resource/key
arguments - MessageFormat arguments
Returns:
The value for the resource id

getImage

public ImageModel getImage(java.lang.String resourceId)
Retrieves an image for the specified Id

Parameters:
resourceId - Image Code
Returns:
The Image or null

getImage

public ImageModel getImage(int size,
                           java.lang.String resourceId)
Retrieves an image for the specified Id

Parameters:
size - Image size
resourceId - Image Code
Returns:
The Image or null

getImage

public ImageModel getImage(java.lang.String resourceId,
                           java.lang.Object param)
Retrieves an image for the specified Id

Parameters:
resourceId - Image Code
param - Markup parameter
Returns:
The Image or null

getImageSrc

public java.lang.String getImageSrc(java.lang.String resourceId)
Retrieves an image for the specified Id

Parameters:
resourceId - Image Code
Returns:
The Image Source

getImageSrc

public java.lang.String getImageSrc(java.lang.String resourceId,
                                    java.lang.Object param)
Retrieves an image for the specified Id

Parameters:
resourceId - Image Code
param - Markup Parameter
Returns:
The Image Source

getImageSrc

public java.lang.String getImageSrc(int size,
                                    java.lang.String resourceId)
Retrieves an image for the specified Id

Parameters:
size - Image size
resourceId - Image Code
Returns:
The Image Source

getColor

public Color getColor(java.lang.String resourceId)
Retrieves an color for the specified Id

Parameters:
resourceId - Color Code
Returns:
The Color or null

getAwtColor

public java.awt.Color getAwtColor(java.lang.String resourceId)
Retrieves an color for the specified Id

Parameters:
resourceId - Color Code
Returns:
The Color or null

getControl

public Control getControl()
Returns:
Gets the Control

isRunAtClient

public boolean isRunAtClient()
This Method checks if the control should run on the client

Returns:
Returns true when the component should run on the client

getStyleId

public java.lang.String getStyleId()
Returns the Style Id of the control. Under some circumstances this method will generate an unique Style id if no style id is explicit set.

Returns:
style id for this control

showComments

public boolean showComments()
This method checks if HTML comments should be written to the output

Returns:
false when comments should be hidden

isDisplayOnly

public boolean isDisplayOnly()
This method checks if a control that is rendered within this painter context has to be "display only"

Returns:
returns true if a control should be rendered as display only

createActionPainter

public ActionPainter createActionPainter(ControlActionDef action)
Creates an ActionPainter. The Painter is used by Controls to render Actions into the user interface

Parameters:
action - ControlAction
Returns:
ActionPainter

createActionPainter

public ActionPainter createActionPainter(ControlActionDef action,
                                         java.lang.String actionName)
Creates an ActionPainter. The Painter is used by Controls to render Actions into the user interface

Parameters:
action - ControlAction
actionName - Additional Action Name
Returns:
ActionPainter

createInput

public org.apache.ecs.html.Input createInput(ImageModel image)
Retrieves an image for the specified Id

Parameters:
image - Image
Returns:
The Image or null

createInput

public org.apache.ecs.html.Input createInput(java.lang.String resourceId)
Retrieves an image for the specified Id

Parameters:
resourceId - Image Code
Returns:
The Image or null

createImage

public org.apache.ecs.html.IMG createImage(ImageModel image)
Retrieves an image for the specified Id

Parameters:
image - Image
Returns:
The Image or null

createImage

public org.apache.ecs.html.IMG createImage(java.lang.String resourceId)
Retrieves an image for the specified Id

Parameters:
resourceId - Image Code
Returns:
The Image or null

createImage

public org.apache.ecs.html.IMG createImage(java.lang.String resourceId,
                                           java.lang.Object param)
Retrieves an image for the specified Id

Parameters:
resourceId - Image Code
param - Markup parameter
Returns:
The Image or null

createImage

public org.apache.ecs.html.IMG createImage(int size,
                                           java.lang.String resourceId)
Retrieves an image for the specified Id

Parameters:
size - Image size
resourceId - Image Code
Returns:
The Image or null

getLocale

public java.util.Locale getLocale()
Gets the Locale Setting for this Control

Specified by:
getLocale in interface RequestContext
Returns:
Locale Setting

localize

public java.lang.String localize(java.lang.String keyOrString)
Localizes a string depending on the localization settings of the Painter context

Parameters:
keyOrString - String Literal or Resource Key
Returns:
localized String

localize

public java.lang.String localize(java.lang.String keyOrString,
                                 java.util.Locale locale)
Localizes a string depending on the localization settings of the Painter context

Parameters:
keyOrString - String Literal or Resource Key
locale - the locale to use
Returns:
localized String

localize

public java.lang.String localize(java.lang.String keyOrString,
                                 java.lang.Object[] arguments)
Localizes a string depending on the localization settings of the Painter context

Parameters:
keyOrString - String Literal or Resource Key
arguments - MessageFormat arguments
Returns:
localized String

localizeKey

public java.lang.String localizeKey(java.lang.String resourceId,
                                    java.lang.Object[] arguments,
                                    boolean returnNull)
Localizes a string depending on the localization settings of the Painter context. A key is searched in the following order:
  1. If no user defined resource bundle is used. The resource is searched under the STRUTS_MESSAGES_KEY.
  2. If an user defined resource bundle is used (key@bundle) the resource is searched in the specified resource bundle.
  3. If the key was not found before, the resource is searched in the framework resource bundle under the key Globals.MESSAGE.

Parameters:
resourceId - The resource key.
arguments - MessageFormat arguments or null
returnNull - controls whether to return null or a not present indicator
Returns:
localized String

removeHtml

public java.lang.String removeHtml(java.lang.Object html)
Removes all HTML formatting from the given HTML-String

Parameters:
html - Object in HTML format
Returns:
String

removeHtml

public java.lang.String removeHtml(java.lang.Object html,
                                   boolean filter)
Removes all HTML formatting from the given HTML-String depending on the filter setting

Parameters:
html - Object in HTML format
filter - Filter
Returns:
String

html

public java.lang.String html(java.lang.Object raw)
Converts a String to an equivalent HTML-String

Parameters:
raw - Object
Returns:
String

html

public java.lang.String html(java.lang.Object raw,
                             boolean filter)
Converts a String to an equivalent HTML-String

Parameters:
raw - Object
filter - Filter
Returns:
String

html

public java.lang.String html(java.lang.Object raw,
                             boolean filter,
                             int maxlength)
Converts a String to an equivalent HTML-String

Parameters:
raw - Object
filter - Filter
maxlength - The maximum number of visible characters
Returns:
String

attr

public java.lang.String attr(java.lang.Object raw)
Converts a String to a valid HTML Attribute

Parameters:
raw - Object
Returns:
String

attr

public java.lang.String attr(java.lang.Object raw,
                             boolean filter)
Converts a String to a valid HTML Attribute

Parameters:
raw - Object
filter - Filter
Returns:
String

attr

public java.lang.String attr(java.lang.Object raw,
                             boolean filter,
                             int maxlength)
Converts a String to a valid HTML Attribute

Parameters:
raw - Object
filter - Filter
maxlength - The maximum number of visible characters
Returns:
String

truncate

public java.lang.String truncate(java.lang.Object obj,
                                 int maxlength)
Truncates a given string to a maximum number of characters

Parameters:
obj - The string to truncate
maxlength - The maximum number of characters
Returns:
truncated string

getSource

public java.lang.String getSource(java.lang.String base,
                                  java.lang.String src)
Returns the localized Image resource name

Parameters:
base - Base Directory or resource Identifier
src - Resource name
Returns:
localized resource name

getSource

public java.lang.String getSource(ImageModel image)
Gets the localized resource name

Parameters:
image - Image Model
Returns:
localized resource name

setAttribute

public void setAttribute(java.lang.String key,
                         java.lang.Object value)
Sets an Attribute for this Painter

Parameters:
key - Attribute Key
value - Attribute Value

removeAttribute

public java.lang.Object removeAttribute(java.lang.String key)
Removes an Attribute for this Painter

Parameters:
key - Attribute Key
Returns:
Value or null

getAttribute

public java.lang.Object getAttribute(java.lang.String key,
                                     boolean searchParent)
Gets an Attribute from the Painter Context hierarchy

Parameters:
key - Attribute Key
searchParent - if set to true the attribute will be search up the PainterContext hierarchy
Returns:
Value or null

hasAttribute

public boolean hasAttribute(java.lang.String key,
                            boolean searchParent)
Gets an Attribute from the Painter Context hierarchy

Parameters:
key - Attribute Key
searchParent - if set to true the attribute will be search up the PainterContext hierarchy
Returns:
Value or null

pushAttributes

public void pushAttributes()
Pushes the current attributes on a stack for later restore


popAttributes

public void popAttributes()
Restores the attributes from the Stack all current attributes are lost



Copyright © 2000-2005 SCC Informationssysteme GmbH. All Rights Reserved.