com.arsdigita.bebop
Class Label

java.lang.Object
  extended bycom.arsdigita.bebop.Completable
      extended bycom.arsdigita.bebop.SimpleComponent
          extended bycom.arsdigita.bebop.TextStylable
              extended bycom.arsdigita.bebop.BlockStylable
                  extended bycom.arsdigita.bebop.Label
All Implemented Interfaces:
Cloneable, Component, Lockable
Direct Known Subclasses:
HelloDate, UserNameLabel

public class Label
extends BlockStylable
implements Cloneable

A text label. The label can be used to generate either some static, fixed text or a new text string for every request. To set a new text string for each request, use the setLabel(String,PageState) method.

Version:
$Id: //core-platform/dev/src/com/arsdigita/bebop/Label.java#11 $
Author:
David Lutterkort

Field Summary
static String BOLD
           
static String ITALIC
           
static String versionId
           
 
Fields inherited from class com.arsdigita.bebop.BlockStylable
ABSBOTTOM, ABSMIDDLE, BASELINE, BOTTOM, CENTER, FULL_WIDTH, INSERT, LEFT, MIDDLE, RIGHT, TEXTTOP, TOP
 
Fields inherited from class com.arsdigita.bebop.SimpleComponent
m_attr
 
Fields inherited from interface com.arsdigita.bebop.Component
BEBOP_XML_NS, CLASS, ID, ON_CLICK, STYLE
 
Constructor Summary
Label()
          Creates a new Label with empty text.
Label(GlobalizedMessage label)
           Creates a new label with the specified text.
Label(GlobalizedMessage label, boolean escaping)
           Creates a new label with the specified text and output escaping turned on if escaping is true.
Label(PrintListener l)
          Creates a new Label that uses the print listener to generate output.
Label(String label)
          Creates a new Label with the specified text.
Label(String label, boolean escaping)
          Creates a new Label with the specified text and output escaping turned on if escaping is true.
Label(String label, String fontWeight)
          Creates a new label with the specified text and fontweight.
 
Method Summary
 void addPrintListener(PrintListener listener)
          Adds a print listener.
protected  Label firePrintEvent(PageState state)
           
 void generateXML(PageState state, Element parent)
          Adds [J]DOM nodes for this component.
 String getFontWeight()
           
 GlobalizedMessage getGlobalizedMessage()
           This should really be getLabel(), but since it was marked STABLE I can't change its return type.
 GlobalizedMessage getGlobalizedMessage(PageState state)
           This should really be getLabel(), but since it was marked STABLE I can't change its return type.
 String getLabel()
          Deprecated. Use getGlobalizedMessage()
 String getLabel(PageState state)
          .
 boolean getOutputEscaping()
           
 void removePrintListener(PrintListener listener)
          Removes a previously added print listener.
 void setFontWeight(String fontWeight)
           
 void setLabel(GlobalizedMessage label)
          Sets the default text for this Label.
 void setLabel(GlobalizedMessage label, PageState state)
          Sets the text for this label using a GlobalizedMessage.
 void setLabel(String label)
          Sets new default text for this Label.
 void setLabel(String label, PageState state)
          Sets new request-specific text for this Label to use on this request.
 void setOutputEscaping(boolean escaping)
          Controls whether output is escaped during transformation, by default true.
 
Methods inherited from class com.arsdigita.bebop.BlockStylable
setBorder, setBorder, setBorderColor, setHorizontalAlignment, setMargin, setMargin, setPadding, setPadding, setVerticalAlignment
 
Methods inherited from class com.arsdigita.bebop.TextStylable
setBackgroundColor, setColor
 
Methods inherited from class com.arsdigita.bebop.SimpleComponent
children, clone, exportAttributes, getAttribute, getClassAttr, getIdAttr, getKey, getMetaDataAttribute, getStyleAttr, hasAttributes, isLocked, isVisible, lock, register, register, respond, setAttribute, setClassAttr, setIdAttr, setKey, setMetaDataAttribute, setStyleAttr, setVisible
 
Methods inherited from class com.arsdigita.bebop.Completable
addCompletionListener, fireCompletionEvent
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values

BOLD

public static final String BOLD
See Also:
Constant Field Values

ITALIC

public static final String ITALIC
See Also:
Constant Field Values
Constructor Detail

Label

public Label()
Creates a new Label with empty text.


Label

public Label(String label)
Creates a new Label with the specified text.

Parameters:
label - the text to display

Label

public Label(String label,
             boolean escaping)
Creates a new Label with the specified text and output escaping turned on if escaping is true. The setting foroutput escaping affects how markup in the label is handled. For example:

Parameters:
label - the text to display

Label

public Label(GlobalizedMessage label)

Creates a new label with the specified text.

Parameters:
label - the text to display

Label

public Label(GlobalizedMessage label,
             boolean escaping)

Creates a new label with the specified text and output escaping turned on if escaping is true.

Parameters:
label - the text to display
escaping - Whether or not to perform output escaping

Label

public Label(PrintListener l)
Creates a new Label that uses the print listener to generate output.

Parameters:
l - the print listener used to produce output

Label

public Label(String label,
             String fontWeight)
Creates a new label with the specified text and fontweight.

Parameters:
label - The text to display
fontWeight - The fontWeight e.g., Label.BOLD
Method Detail

getLabel

public String getLabel(PageState state)
. Although it is not recommended, this method may be overridden to dynamically generate the text of the label. Overriding code may need the page state.

If possible, derived classes should override getLabel() instead, which is called from this method. As long as we don't have a static method to obtain ApplicationContext, this is a way to get the RequestContext (that is, to determine the locale). When ApplicationContext gets available, that will become the suggested way for overriding code to get context.

Parameters:
state - the current page state
Returns:
the string produced for this label

getLabel

public String getLabel()
Deprecated. Use getGlobalizedMessage()

. This method may be overridden to dynamically generate the default text of the label.

Returns:
the string produced for this label.

getGlobalizedMessage

public GlobalizedMessage getGlobalizedMessage()

This should really be getLabel(), but since it was marked STABLE I can't change its return type.

Returns:
the default label to display.

getGlobalizedMessage

public GlobalizedMessage getGlobalizedMessage(PageState state)

This should really be getLabel(), but since it was marked STABLE I can't change its return type.

Returns:
the label to display for this request, or if state is null, the default label

setLabel

public void setLabel(String label)
Sets new default text for this Label.

Parameters:
label - The new label text; will be used as a key into the current ResourceBundle if possible, or displayed literally.

setLabel

public void setLabel(String label,
                     PageState state)
Sets new request-specific text for this Label to use on this request. If state is null, then sets the default text instead.

Parameters:
label - The new label text; will be used as a key into the current ResourceBundle if possible, or displayed literally.
state - the page state

setLabel

public void setLabel(GlobalizedMessage label,
                     PageState state)
Sets the text for this label using a GlobalizedMessage.

Parameters:
label - The GlobalizedMessage containing the label text or the lookup key to use in the ResourceBundle
state - the current page state; if null, sets the default text for all requests.

setLabel

public void setLabel(GlobalizedMessage label)
Sets the default text for this Label.

Parameters:
label - The GlobalizedMessage containing the label text or the lookup key to use in the ResourceBundle

getOutputEscaping

public final boolean getOutputEscaping()

setOutputEscaping

public final void setOutputEscaping(boolean escaping)
Controls whether output is escaped during transformation, by default true. If true, it will be printed literally, and the user will see <b>. When false, the browser will interpret as a bold tag.


getFontWeight

public final String getFontWeight()

setFontWeight

public void setFontWeight(String fontWeight)

addPrintListener

public void addPrintListener(PrintListener listener)
                      throws IllegalStateException,
                             IllegalArgumentException
Adds a print listener. Only one print listener can be set for a label, since the PrintListener is expected to modify the target of the PrintEvent.

Parameters:
listener - the print listener
Throws:
IlegalArgumentException - if listener is null.
IllegalStateException - if a print listener has previously been added.
IllegalArgumentException

removePrintListener

public void removePrintListener(PrintListener listener)
                         throws IllegalArgumentException
Removes a previously added print listener. If listener is not the listener that was added with addPrintListener, an IllegalArgumentException will be thrown.

Parameters:
listener - the listener that was added with addPrintListener
Throws:
IllegalArgumentException - if listener is not the currently registered print listener or is null.

generateXML

public void generateXML(PageState state,
                        Element parent)
Description copied from class: SimpleComponent
Adds [J]DOM nodes for this component. Specifically for base class SimpleComponent, does nothing.

Specified by:
generateXML in interface Component
Overrides:
generateXML in class SimpleComponent

firePrintEvent

protected Label firePrintEvent(PageState state)


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 21 2004:2337 UTC