org.zkoss.zul
Class Label

java.lang.Object
  extended by org.zkoss.zk.ui.AbstractComponent
      extended by org.zkoss.zk.ui.HtmlBasedComponent
          extended by org.zkoss.zul.impl.XulElement
              extended by org.zkoss.zul.Label
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, HtmlBasedComponent, Component, Scope, ComponentCtrl, Label, XulElement

public class Label
extends XulElement
implements Label

A label.

Author:
tomyeh
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.zkoss.zk.ui.HtmlBasedComponent
HtmlBasedComponent.ExtraCtrl
 
Nested classes/interfaces inherited from class org.zkoss.zk.ui.AbstractComponent
AbstractComponent.Children
 
Field Summary
 
Fields inherited from class org.zkoss.zk.ui.HtmlBasedComponent
_zclass, RS_NO_DISPLAY, RS_NO_HEIGHT, RS_NO_WIDTH
 
Fields inherited from class org.zkoss.zk.ui.AbstractComponent
_visible
 
Fields inherited from interface org.zkoss.zk.ui.Component
APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPE
 
Constructor Summary
Label()
           
Label(java.lang.String value)
           
 
Method Summary
 java.lang.String getEncodedText()
          Returns the text for generating HTML tags (Internal Use Only).
 int getMaxlength()
          Returns the maximal length of the label.
 java.lang.String getOuterAttrs()
          Returns the exterior attributes for generating the enclosing HTML tag; never return null.
 java.lang.String getValue()
          Returns the value.
 java.lang.String getZclass()
          Returns the Style of label Default: "z-label"
 void invalidate()
          Invalidates this component by setting the dirty flag such that it will be redraw the whole content later.
 boolean isChildable()
          No child is allowed.
 boolean isHyphen()
          Returns whether to hyphenate a long word if maxlength is specified.
 boolean isIdRequired()
          Whether to generate the value directly without ID.
 boolean isMultiline()
          Returns whether to preserve the new line and the white spaces at the begining of each line.
 boolean isPre()
          Returns whether to preserve the white spaces, such as space, tab and new line.
 void redraw(java.io.Writer out)
          Redraws this component.
 void setHyphen(boolean hyphen)
          Sets whether to hyphen a long word if maxlength is specified.
 void setMaxlength(int maxlength)
          Sets the maximal length of the label.
 void setMultiline(boolean multiline)
          Sets whether to preserve the new line and the white spaces at the begining of each line.
 void setPre(boolean pre)
          Sets whether to preserve the white spaces, such as space, tab and new line.
 void setValue(java.lang.String value)
          Sets the value.
 
Methods inherited from class org.zkoss.zul.impl.XulElement
getAction, getActionAttrs, getAllOnClickAttrs, getContext, getCtrlKeys, getInnerAttrs, getPopup, getTooltip, setAction, setContext, setContext, setCtrlKeys, setPopup, setPopup, setTooltip, setTooltip
 
Methods inherited from class org.zkoss.zk.ui.HtmlBasedComponent
focus, getAllOnClickAttrs, getDraggable, getDroppable, getHeight, getLeft, getMoldSclass, getRealSclass, getRealStyle, getRealStyleFlags, getSclass, getStyle, getTooltiptext, getTop, getWidth, getZindex, getZIndex, newExtraCtrl, setClass, setDraggable, setDroppable, setFocus, setHeight, setLeft, setMoldSclass, setSclass, setStyle, setTooltiptext, setTop, setWidth, setZclass, setZindex, setZIndex
 
Methods inherited from class org.zkoss.zk.ui.AbstractComponent
addAnnotation, addAnnotation, addEventHandler, addEventListener, addForward, addForward, addForward, addForward, addMoved, addSharedAnnotationMap, addSharedEventHandlerMap, appendAsapAttr, appendAsapAttr, appendChild, applyProperties, beforeChildAdded, beforeChildRemoved, beforeParentChanged, clone, containsVariable, detach, disableClientUpdate, equals, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotation, getAnnotations, getAnnotations, getAttribute, getAttribute, getAttributes, getAttributes, getChildren, getCommand, getDefinition, getDesktop, getEventHandler, getEventHandlerNames, getExtraCtrl, getFellow, getFellowIfAny, getFellows, getFirstChild, getId, getLastChild, getListenerIterator, getMold, getMoldURI, getNamespace, getNextSibling, getPage, getParent, getPreviousSibling, getRoot, getSpaceOwner, getUuid, getVariable, hasFellow, insertBefore, isAsapRequired, isInvalidated, isListenerAvailable, isVisible, newChildren, onChildAdded, onChildRemoved, onDrawNewChild, onPageAttached, onPageDetached, onWrongValue, removeAttribute, removeAttribute, removeChild, removeEventListener, removeForward, removeForward, response, sessionDidActivate, sessionWillPassivate, setAttribute, setAttribute, setComponentDefinition, setId, setMold, setPage, setPageBefore, setParent, setVariable, setVisible, smartUpdate, smartUpdate, smartUpdate, smartUpdateDeferred, smartUpdateValues, toString, unsetVariable
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.zkoss.zul.impl.api.XulElement
getAction, getContext, getCtrlKeys, getPopup, getTooltip, setAction, setContext, setContext, setCtrlKeys, setPopup, setPopup, setTooltip, setTooltip
 
Methods inherited from interface org.zkoss.zk.ui.api.HtmlBasedComponent
focus, getHeight, getLeft, getSclass, getStyle, getTooltiptext, getTop, getWidth, getZindex, getZIndex, setDraggable, setDroppable, setFocus, setHeight, setLeft, setSclass, setStyle, setTooltiptext, setTop, setWidth, setZclass, setZindex, setZIndex
 
Methods inherited from interface org.zkoss.zk.ui.Component
addEventListener, addForward, addForward, addForward, addForward, appendChild, applyProperties, clone, containsVariable, detach, getAttribute, getAttribute, getAttributes, getAttributes, getChildren, getDefinition, getDesktop, getFellow, getFellowIfAny, getFellows, getFirstChild, getId, getLastChild, getListenerIterator, getMold, getNamespace, getNextSibling, getPage, getParent, getPreviousSibling, getRoot, getSpaceOwner, getUuid, getVariable, insertBefore, isInvalidated, isListenerAvailable, isVisible, removeAttribute, removeAttribute, removeChild, removeEventListener, removeForward, removeForward, setAttribute, setAttribute, setId, setMold, setPage, setPageBefore, setParent, setVariable, setVisible, unsetVariable
 

Constructor Detail

Label

public Label()

Label

public Label(java.lang.String value)
Method Detail

getValue

public java.lang.String getValue()
Returns the value.

Default: "".

Specified by:
getValue in interface Label

setValue

public void setValue(java.lang.String value)
Sets the value.

Specified by:
setValue in interface Label

getMaxlength

public int getMaxlength()
Returns the maximal length of the label.

Noteice:

hyphen="false" and pre="false"
maxlength is the maximal length to display. Exceeding part is truncated.
hyphen="true"
maxlength is the maximal length of each line, and hyphenation is added if a line exceeds maxlength.
hyphen="false" and pre="true"
maxlength has no effect.
maxlength=0
hyphen has no effect

Since 3.0.4, you can set the style class (@{link #setSclass}) to "word-wrap" to wrap a long word instead of using the hyphen and maxlength property. However, word-wrap is not applicable to Opera (it works fine with FF, IE and Safari).

Specified by:
getMaxlength in interface Label

setMaxlength

public void setMaxlength(int maxlength)
Sets the maximal length of the label.

See getMaxlength() for the relationship among pre, hyphen and maxlength.

Specified by:
setMaxlength in interface Label

isPre

public boolean isPre()
Returns whether to preserve the white spaces, such as space, tab and new line.

It is the same as style="white-space:pre". However, IE has a bug when handling such style if the content is updated dynamically. Refer to Bug 1455584.

See getMaxlength() for the relationship among pre, hyphen and maxlength.

Note: the new line is preserved either isPre() or isMultiline() returns true. In other words, pre implies multiline

Specified by:
isPre in interface Label

setPre

public void setPre(boolean pre)
Sets whether to preserve the white spaces, such as space, tab and new line.

See getMaxlength() for the relationship among pre, hyphen and maxlength.

Specified by:
setPre in interface Label

isMultiline

public boolean isMultiline()
Returns whether to preserve the new line and the white spaces at the begining of each line.

Note: the new line is preserved either isPre() or isMultiline() returns true. In other words, pre implies multiline

Specified by:
isMultiline in interface Label

setMultiline

public void setMultiline(boolean multiline)
Sets whether to preserve the new line and the white spaces at the begining of each line.

Specified by:
setMultiline in interface Label

isHyphen

public boolean isHyphen()
Returns whether to hyphenate a long word if maxlength is specified.

Since 3.0.4, you can set the style class (@{link #setSclass}) to "word-wrap" to wrap a long word instead of using the hyphen and maxlength property. However, word-wrap is not applicable to Opera (it works fine with FF, IE and Safari).

See getMaxlength() for the relationship among pre, hyphen and maxlength.

Specified by:
isHyphen in interface Label

setHyphen

public void setHyphen(boolean hyphen)
Sets whether to hyphen a long word if maxlength is specified.

See getMaxlength() for the relationship among pre, hyphen and maxlength.

Specified by:
setHyphen in interface Label

isIdRequired

public boolean isIdRequired()
Whether to generate the value directly without ID.

Used only for component generated. Not for applications.

Since:
3.0.0

getEncodedText

public java.lang.String getEncodedText()
Returns the text for generating HTML tags (Internal Use Only).

Used only for component generation. Not for applications.


getOuterAttrs

public java.lang.String getOuterAttrs()
Description copied from class: HtmlBasedComponent
Returns the exterior attributes for generating the enclosing HTML tag; never return null.

Used only by component developers.

Default: Generates the tooltip text, style, sclass, draggable and droppable attribute if necessary. In other words, the corresponding attribute is generated if HtmlBasedComponent.getTooltiptext(), HtmlBasedComponent.getRealStyle(), HtmlBasedComponent.getSclass(), HtmlBasedComponent.getDraggable(), HtmlBasedComponent.getDroppable() are defined.

You have to call both HtmlBasedComponent.getOuterAttrs() and HtmlBasedComponent.getInnerAttrs() to generate complete attributes.

For simple components that all attributes are put on the outest HTML element, all you need is as follows.

<xx id="${self.uuid}"${self.outerAttrs}${self.innerAttrs}>

If you want to put attributes in a nested HTML element, you shall use the following pattern. Notice: if HtmlBasedComponent.getInnerAttrs() in a different tag, the tag must be named with "${self.uuid}!real".

<xx id="${self.uuid}"${self.outerAttrs}>
 <yy id="${self.uuid}!real"${self.innerAttrs}>...

Note: This class handles non-deferrable event listeners automatically. However, you have to invoke AbstractComponent.appendAsapAttr(java.lang.StringBuffer, java.lang.String) for each event the component handles in HtmlBasedComponent.getOuterAttrs() as follows.


        appendAsapAttr(sb, Events.ON_OPEN);
  appendAsapAttr(sb, Events.ON_CHANGE);

Theorectically, you could put any attributes in either HtmlBasedComponent.getInnerAttrs() or HtmlBasedComponent.getOuterAttrs(). However, zkau.js assumes all attributes are put at the outer one. If you want something different, you have to provide your own setAttr (refer to how checkbox is implemented).

Overrides:
getOuterAttrs in class XulElement

getZclass

public java.lang.String getZclass()
Returns the Style of label

Default: "z-label"

Specified by:
getZclass in interface HtmlBasedComponent
Overrides:
getZclass in class HtmlBasedComponent
See Also:
HtmlBasedComponent.getSclass(), HtmlBasedComponent.getRealSclass()

invalidate

public void invalidate()
Description copied from interface: Component
Invalidates this component by setting the dirty flag such that it will be redraw the whole content later.

It can be called only in the request-processing and event-processing phases; excluding the redrawing phase.

Specified by:
invalidate in interface Component
Overrides:
invalidate in class AbstractComponent

redraw

public void redraw(java.io.Writer out)
            throws java.io.IOException
Description copied from class: AbstractComponent
Redraws this component. This method implements the mold mechanism.
  1. It first invokes AbstractComponent.getMoldURI() to retrieve the mold to redraw. The mold is either an URI (String) or a ComponentRenderer instance.
  2. If URI, it invokes Execution.include(java.io.Writer, java.lang.String, java.util.Map, int) to generate the output.
  3. If a ComponentRenderer instance, ComponentRenderer.render(org.zkoss.zk.ui.Component, java.io.Writer) is called to generate the output.
  4. Specified by:
    redraw in interface Component
    Overrides:
    redraw in class HtmlBasedComponent
    Throws:
    java.io.IOException

isChildable

public boolean isChildable()
No child is allowed.

Specified by:
isChildable in interface Component
Overrides:
isChildable in class AbstractComponent


Copyright &copy; 2005-2009 Potix Corporation. All Rights Reserved. SourceForge.net Logo