com.cc.framework.ui.painter
Class ControlPainter

java.lang.Object
  extended bycom.cc.framework.ui.painter.ControlPainter
Direct Known Subclasses:
DefPainterBase, HtmlPainterBase

public abstract class ControlPainter
extends java.lang.Object

This Class is responsible for the HTML-generation (rendering) of a Control

Since:
1.0
Version:
$Revision: 1.68 $
Author:
Harald Schulz

Field Summary
private  FramePainter framePainter
          The painter that is used to create the frame element
protected  org.apache.commons.logging.Log log
          Commons Logging instance.
private  PainterContext painterContext
          PageContext of the JSP page
 
Constructor Summary
ControlPainter()
          Constructor for ControlPainter
ControlPainter(PainterContext painterContext)
          Constructor for ControlPainter
 
Method Summary
 void ajaxPaint(java.io.Writer out)
          Writes an AJAX XML Stream for the control
 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 beginPaint(java.io.Writer out)
          Method beginPaint
 ActionPainter createActionPainter(ControlActionDef action)
          Creates an ActionPainter.
 ActionPainter createActionPainter(ControlActionDef action, java.lang.String actionName)
          Creates an ActionPainter.
 org.apache.ecs.ConcreteElement createElement()
          Creates the HTML-Element.
 org.apache.ecs.html.IMG createImage(ImageModel image)
          Creates an HTML image Tag for the specified image model
 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
 org.apache.ecs.ConcreteElement createSpacer(int height, int width)
          Creates a spacer image with the given dimension
 org.apache.ecs.ConcreteElement createSpacer(int height, java.lang.String width)
          Creates a spacer image with the given dimension
 org.apache.ecs.ConcreteElement createSpacer(java.lang.String height, java.lang.String width)
          Creates a spacer image with the given dimension
 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!
protected  void doAddDecorationsToRow(org.apache.ecs.html.TR row, int rowSpan)
          Attaches all decoration elements that are stored in the painter context to the control HTML table row.
protected  void doAddDecorationsToRow(org.apache.ecs.html.TR row, int rowSpan, java.util.Collection decorations)
          Attaches all decoration elements that are stored in the painter context to the control HTML table row.
protected  void doAfterCreate()
          This template method gets called after element creation
protected  org.apache.ecs.ConcreteElement doAttachDecorations(org.apache.ecs.ConcreteElement control)
          Attaches all decoration elements that are stored in the painter context to the left side of the control.
protected  void doBeforeCreate()
          This template method gets called before element creation
protected abstract  org.apache.ecs.ConcreteElement doCreateElement()
          Creates the HTML-Element.
 java.lang.String encodeURL(java.lang.String src)
          Encodes an URL Some characters present the possibility of being misunderstood within URLs for various reasons.
 void endPaint(java.io.Writer out)
          This Method writes the Control as an HTML-String to the Output from the JSP-Page.
 java.lang.String forceControlName()
           
 java.lang.String getAsString(Converter converter, java.lang.Object value)
          Uses a Bean Converter to convert the given object to a String representation.
 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
 java.lang.String getContextPath()
          Returns the portion of the request URI that indicates the context of the request
 java.lang.String getControlName()
           
protected  java.util.Collection getDecorationsOnce()
          Removes the decoration collection from the Painter Context this method can only be called once. subsequent calls will return a null pointer!
 java.lang.String getElementClass(int type)
          The method returns the HTML style class required for a list or treelist control.
 java.lang.String getElementName()
          Retrieves the name of the HTML element.
protected  FramePainter getFramePainter()
          Returns the FramePainter for this Control.
 java.lang.String getFrameworkString(java.lang.String resourceId)
          Retrieves an framework String for the specified Id
 java.lang.String getFrameworkString(java.lang.String resourceId, java.lang.Object[] arguments)
          Retrieves an framework String for the specified Id
 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()
          Retrieves the current Locale
 javax.servlet.jsp.PageContext getPageContext()
          Returns the JSP page context
 PainterContext getPainterContext()
          Gets the Painter Context
 Principal getPrincipal()
          Returns the Principal Object
 javax.servlet.http.HttpServletRequest getRequest()
          Deprecated. use session()
 javax.servlet.http.HttpServletResponse getResponse()
          Deprecated. use response()
 javax.servlet.http.HttpSession getSession()
          Deprecated. use session()
 java.lang.String getSmartCaption(java.lang.String caption, java.lang.String detail)
          Method getSmartCaption
 java.lang.String getSmartDetail(java.lang.String caption, java.lang.String detail)
          Method getSmartDetail
 java.lang.String getSource(ImageModel image)
          Gets the localized resource name
 java.lang.String getSource(java.lang.String base, java.lang.String src)
          Gets the localized Image resource name
 java.lang.String getStringResource(java.lang.String resourceId)
          Retrieves an String for the specified Id
 java.lang.String getStyleId()
          Returns the Style Id of the control.
 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
 void init(PainterContext painterContext)
          Sets the painter context
 boolean isRunAtClient()
          This Method checks if the control should run on the client
 java.lang.String localize(java.lang.String raw)
          Localizes a string depending on the localization settings of the Painter context
 java.lang.String localize(java.lang.String raw, java.util.Locale locale)
          Localizes a string depending on the localization settings of the Painter context
 java.lang.String localize(java.lang.String raw, java.lang.Object[] arguments)
          Localizes a string depending on the localization settings of the Painter context
 void paint(java.io.Writer out)
          Method paint
protected  java.lang.String removeHtml(java.lang.Object html)
          Removes all HTML formatting from the given HTML-String
protected  java.lang.String removeHtml(java.lang.Object html, boolean filter)
          Removes all HTML formatting from the given HTML-String depending on the filter setting
 javax.servlet.http.HttpServletRequest request()
          Returns the HTTP Request
 javax.servlet.http.HttpServletResponse response()
          Returns the HTTP Response
 javax.servlet.http.HttpSession session()
          Gets the session object
 boolean showComments()
          This method checks if HTML comments should be written to the output
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected org.apache.commons.logging.Log log
Commons Logging instance.


painterContext

private PainterContext painterContext
PageContext of the JSP page


framePainter

private FramePainter framePainter
The painter that is used to create the frame element

Constructor Detail

ControlPainter

public ControlPainter()
Constructor for ControlPainter


ControlPainter

public ControlPainter(PainterContext painterContext)
Constructor for ControlPainter

Parameters:
painterContext - The PainterContext
Method Detail

init

public void init(PainterContext painterContext)
Sets the painter context

Parameters:
painterContext - The PainterContext

getFramePainter

protected FramePainter getFramePainter()
Returns the FramePainter for this Control. The method will call doCreateFramePainter to create a new FramePainter at the first access.

Returns:
FaramePainter

getPageContext

public javax.servlet.jsp.PageContext getPageContext()
Returns the JSP page context

Returns:
The JSP page context

getPrincipal

public Principal getPrincipal()
Returns the Principal Object

Returns:
Principal

getContextPath

public java.lang.String getContextPath()
Returns the portion of the request URI that indicates the context of the request

Returns:
String

showComments

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

Returns:
false when comments should be hidden

request

public javax.servlet.http.HttpServletRequest request()
Returns the HTTP Request

Returns:
the HttpServletRequest

response

public javax.servlet.http.HttpServletResponse response()
Returns the HTTP Response

Returns:
the HttpServletResponse

session

public javax.servlet.http.HttpSession session()
Gets the session object

Returns:
HttpSession

getRequest

public javax.servlet.http.HttpServletRequest getRequest()
Deprecated. use session()

Returns the HttpServletRequest

Returns:
The HttpServletRequest

getResponse

public javax.servlet.http.HttpServletResponse getResponse()
Deprecated. use response()

Returns the HttpServletResponse

Returns:
The HttpServletResponse

getSession

public javax.servlet.http.HttpSession getSession()
Deprecated. use session()

Returns the HttpSession

Returns:
The HttpSession or null

getLocale

public java.util.Locale getLocale()
Retrieves the current Locale

Returns:
Locale

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

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

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

getElementClass

public java.lang.String getElementClass(int type)
The method returns the HTML style class required for a list or treelist control.

Parameters:
type - The required style class
Returns:
The style class

doCreateElement

protected abstract org.apache.ecs.ConcreteElement doCreateElement()
Creates the HTML-Element. This Method must be implemented by the concrete Sub-Class

Returns:
ConcreteElement

getDecorationsOnce

protected java.util.Collection getDecorationsOnce()
Removes the decoration collection from the Painter Context

this method can only be called once. subsequent calls will return a null pointer!

Returns:
The current decoration collection

doAddDecorationsToRow

protected void doAddDecorationsToRow(org.apache.ecs.html.TR row,
                                     int rowSpan)
Attaches all decoration elements that are stored in the painter context to the control HTML table row. The Decorations collection will be removed from the painter context.

Parameters:
row - The row where the decorations should be attached
rowSpan - the rows that a decoration element should span

doAddDecorationsToRow

protected void doAddDecorationsToRow(org.apache.ecs.html.TR row,
                                     int rowSpan,
                                     java.util.Collection decorations)
Attaches all decoration elements that are stored in the painter context to the control HTML table row. The Decorations collection will be removed from the painter context.

Parameters:
row - The row where the decorations should be attached
rowSpan - the rows that a decoration element should span
decorations - list with decorations

doAttachDecorations

protected org.apache.ecs.ConcreteElement doAttachDecorations(org.apache.ecs.ConcreteElement control)
Attaches all decoration elements that are stored in the painter context to the left side of the control. The Decorations collection will be removed from the painter context.

Parameters:
control - The Controls HTML representation
Returns:
returns the decorated Control

encodeURL

public java.lang.String encodeURL(java.lang.String src)
Encodes an URL Some characters present the possibility of being misunderstood within URLs for various reasons. For this reason these characters are always be encoded. For example 'Less Than' symbol ("<"), Greater Than' symbol (">"), Left Curly Brace ("{"), Right Curly Brace ("}"), Vertical Bar/Pipe ("|"), Backslash ("\"), Caret ("^"), Tilde ("~"), Left Square Bracket ("["), Right Square Bracket ("]"), Grave Accent ("`"), Percent character ("%").

Parameters:
src - The URL which should be encoded
Returns:
String The encoded state.

getSmartCaption

public java.lang.String getSmartCaption(java.lang.String caption,
                                        java.lang.String detail)
Method getSmartCaption

Parameters:
caption - Caption
detail - Detail
Returns:
String

getSmartDetail

public java.lang.String getSmartDetail(java.lang.String caption,
                                       java.lang.String detail)
Method getSmartDetail

Parameters:
caption - Caption
detail - Detail
Returns:
String

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

removeHtml

protected 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

protected 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

getPainterContext

public PainterContext getPainterContext()
Gets the Painter Context

Returns:
PainterContext

localize

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

Parameters:
raw - String
Returns:
localized String

localize

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

Parameters:
raw - String
locale - the Locale
Returns:
localized String

localize

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

Parameters:
raw - String
arguments - MessageFormat arguments
Returns:
localized String

getSource

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

Parameters:
base - Base Directory or resource key
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

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

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(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

getImage

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

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

getStringResource

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

Parameters:
resourceId - The resource id
Returns:
The String Source

getFrameworkString

public java.lang.String getFrameworkString(java.lang.String resourceId)
Retrieves an framework String for the specified Id

Parameters:
resourceId - The resource id
Returns:
The String Source

getFrameworkString

public java.lang.String getFrameworkString(java.lang.String resourceId,
                                           java.lang.Object[] arguments)
Retrieves an framework String for the specified Id

Parameters:
resourceId - The resource id
arguments - MessageFormat arguments
Returns:
The String Source

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

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

createSpacer

public org.apache.ecs.ConcreteElement createSpacer(int height,
                                                   int width)
Creates a spacer image with the given dimension

Parameters:
height - spacer height
width - spacer width
Returns:
Spacer Image

createSpacer

public org.apache.ecs.ConcreteElement createSpacer(int height,
                                                   java.lang.String width)
Creates a spacer image with the given dimension

Parameters:
height - spacer height
width - spacer width
Returns:
Spacer Image

createSpacer

public org.apache.ecs.ConcreteElement createSpacer(java.lang.String height,
                                                   java.lang.String width)
Creates a spacer image with the given dimension

Parameters:
height - spacer height
width - spacer width
Returns:
Spacer Image

createImage

public org.apache.ecs.html.IMG createImage(ImageModel image)
Creates an HTML image Tag for the specified image model

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

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

getControlName

public java.lang.String getControlName()
Returns:
returns the name of the control (the name of the java bean) or null when the control was not specified with a "name" and/or "property" attribute

forceControlName

public java.lang.String forceControlName()
Returns:
returns the name of the control (the name of the java bean) or a generated name

doBeforeCreate

protected void doBeforeCreate()
This template method gets called before element creation


doAfterCreate

protected void doAfterCreate()
This template method gets called after element creation


createElement

public final org.apache.ecs.ConcreteElement createElement()
Creates the HTML-Element. This Method must be implemented by the concrete Sub-Class

Returns:
ConcreteElement or null

paint

public final void paint(java.io.Writer out)
                 throws java.io.IOException
Method paint

Parameters:
out - JspWriter
Throws:
java.io.IOException - If an input or output exception occurred

ajaxPaint

public void ajaxPaint(java.io.Writer out)
               throws java.io.IOException
Writes an AJAX XML Stream for the control

Parameters:
out - JspWriter
Throws:
java.io.IOException - If an input or output exception occurred

beginPaint

public final void beginPaint(java.io.Writer out)
                      throws java.io.IOException
Method beginPaint

Parameters:
out - Writer
Throws:
java.io.IOException - If an input or output exception occurred

endPaint

public final void endPaint(java.io.Writer out)
                    throws java.io.IOException
This Method writes the Control as an HTML-String to the Output from the JSP-Page.

Parameters:
out - The Writer
Throws:
java.io.IOException - Signals that an I/O exception of some sort has occurred


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