org.zkoss.zk.ui
Class HtmlNativeComponent

java.lang.Object
  extended by org.zkoss.zk.ui.AbstractComponent
      extended by org.zkoss.zk.ui.HtmlNativeComponent
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Component, DynamicPropertied, DynamicTag, Native, NonFellow, Scope, ComponentCtrl

public class HtmlNativeComponent
extends AbstractComponent
implements DynamicTag, Native

A component used to represent XML elements that are associated with the native namespace (http://www.zkoss.org/2005/zk/native).

It contains the content that shall be sent directly to client. It has three parts: prolog, children and epilog. The prolog (getPrologContent()) and epilog (getEpilogContent()) are both String.

When this component is renderred (redraw(java.io.Writer)), it generates the prolog first, the children and then the epilog.

Since:
3.0.0
Author:
tomyeh
See Also:
Serialized Form

Nested Class Summary
protected  class HtmlNativeComponent.ExtraCtrl
           
static class HtmlNativeComponent.HtmlHelper
          The HTML helper.
 
Nested classes/interfaces inherited from class org.zkoss.zk.ui.AbstractComponent
AbstractComponent.Children
 
Nested classes/interfaces inherited from interface org.zkoss.zk.ui.ext.Native
Native.Helper
 
Field Summary
 
Fields inherited from interface org.zkoss.zk.ui.Component
APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPE
 
Fields inherited from interface org.zkoss.zk.ui.sys.ComponentCtrl
CE_BUSY_IGNORE, CE_DUPLICATE_IGNORE, CE_IMPORTANT, CE_NON_DEFERRABLE, CE_REPEAT_IGNORE
 
Constructor Summary
HtmlNativeComponent()
          Contructs a HtmlNativeComponent component.
HtmlNativeComponent(java.lang.String tag)
          Constructs a HtmlNativeComponent component with the specified tag name.
HtmlNativeComponent(java.lang.String tag, java.lang.String prolog, java.lang.String epilog)
          Contructs a HtmlNativeComponent component with the specified prolog and epilog.
 
Method Summary
 void addDeclaredNamespace(Namespace ns)
          Adds a declared namespace.
 java.util.List<Namespace> getDeclaredNamespaces()
          Returns a readonly list of the declared namespaces (Namespace), or empty if no declared namespace.
 java.lang.Object getDynamicProperty(java.lang.String name)
          Returns the property value of the specified name.
 java.lang.String getEpilogContent()
          Returns the epilog content.
 java.lang.Object getExtraCtrl()
          Returns the extra controls that tell ZK how to handle this component specially.
 Native.Helper getHelper()
          Returns the helper to generate the output of the native components.
 java.lang.String getPrologContent()
          Returns the prolog content.
 java.lang.String getTag()
          Returns the tag name, or null if plain text.
 java.lang.String getWidgetClass()
          Returns the widget class, "zk.Native".
 boolean hasDynamicProperty(java.lang.String name)
          Returns whether a dynamic property is defined.
 boolean hasTag(java.lang.String tag)
          Returns whether the specified tag is allowed.
 void redraw(java.io.Writer out)
          Redraws this component and all its descendants.
protected  void renderProperties(ContentRenderer renderer)
          Called by (ComponentCtrl.redraw(java.io.Writer)) to render the properties, excluding the enclosing tag and children.
 void setDynamicProperty(java.lang.String name, java.lang.Object value)
          Sets a property with the specified name and value.
 void setEpilogContent(java.lang.String epilog)
          Sets the epilog content.
 void setId(java.lang.String id)
          Sets the ID.
 void setPrologContent(java.lang.String prolog)
          Sets the prolog content.
 void setTag(java.lang.String tag)
          Sets the tag name.
 boolean setVisible(boolean visible)
          Sets whether this component is visible.
 
Methods inherited from class org.zkoss.zk.ui.AbstractComponent
addAnnotation, addAnnotation, addClientEvent, addEventHandler, addEventListener, addEventListener, addForward, addForward, addForward, addForward, addMoved, addScopeListener, addSharedAnnotationMap, addSharedEventHandlerMap, appendChild, applyProperties, beforeChildAdded, beforeChildRemoved, beforeParentChanged, clone, detach, didActivate, didActivate, didDeserialize, didDeserialize, disableClientUpdate, equals, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotation, getAnnotations, getAnnotations, getAnnotations, getAttribute, getAttribute, getAttribute, getAttributeOrFellow, getAttributes, getAttributes, getAuService, getAutag, getChildren, getClientEvents, getDefaultMold, getDefinition, getDesktop, getEventHandler, getEventHandlerNames, getEventListenerMap, getEventListeners, getFellow, getFellow, getFellowIfAny, getFellowIfAny, getFellows, getFirstChild, getId, getLastChild, getListenerIterator, getMold, getNextSibling, getPage, getParent, getPreviousSibling, getRoot, getSpaceOwner, getStubonly, getTemplate, getTemplateNames, getUuid, getWidgetAttribute, getWidgetAttributeNames, getWidgetListener, getWidgetListenerNames, getWidgetOverride, getWidgetOverrideNames, hasAttribute, hasAttribute, hasAttribute, hasAttributeOrFellow, hasFellow, hasFellow, insertBefore, invalidate, isChildable, isInvalidated, isListenerAvailable, isVisible, onChildAdded, onChildRemoved, onPageAttached, onPageDetached, onWrongValue, query, queryAll, redrawChildren, removeAttribute, removeAttribute, removeAttribute, removeChild, removeEventListener, removeForward, removeForward, removeScopeListener, render, render, render, replace, response, response, service, service, sessionDidActivate, sessionWillPassivate, setAttribute, setAttribute, setAttribute, setAuService, setAutag, setDefinition, setDefinition, setMold, setPage, setPageBefore, setParent, setStubonly, setStubonly, setTemplate, setVisibleDirectly, setWidgetAttribute, setWidgetClass, setWidgetListener, setWidgetOverride, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdateWidgetListener, smartUpdateWidgetOverride, toString, updateByClient, willPassivate, willPassivate, willSerialize, willSerialize
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

HtmlNativeComponent

public HtmlNativeComponent()
Contructs a HtmlNativeComponent component.


HtmlNativeComponent

public HtmlNativeComponent(java.lang.String tag)
Constructs a HtmlNativeComponent component with the specified tag name.

Parameters:
tag - the tag name. If null or empty, plain text is assumed.

HtmlNativeComponent

public HtmlNativeComponent(java.lang.String tag,
                           java.lang.String prolog,
                           java.lang.String epilog)
Contructs a HtmlNativeComponent component with the specified prolog and epilog.

Parameters:
tag - the tag name. If null or empty, plain text is assumed.
prolog - the content right before the children, if any.
epilog - the content right after the children, if any.
Method Detail

getWidgetClass

public java.lang.String getWidgetClass()
Returns the widget class, "zk.Native".

Specified by:
getWidgetClass in interface Component
Overrides:
getWidgetClass in class AbstractComponent
Since:
5.0.0
See Also:
Component.setWidgetClass(java.lang.String)

getTag

public java.lang.String getTag()
Returns the tag name, or null if plain text.


getDeclaredNamespaces

public java.util.List<Namespace> getDeclaredNamespaces()
Description copied from interface: Native
Returns a readonly list of the declared namespaces (Namespace), or empty if no declared namespace.

Specified by:
getDeclaredNamespaces in interface Native

addDeclaredNamespace

public void addDeclaredNamespace(Namespace ns)
Description copied from interface: Native
Adds a declared namespace. The added declared namespace will be generated to the output.

Specified by:
addDeclaredNamespace in interface Native
Parameters:
ns - the namespace (never null).

getPrologContent

public java.lang.String getPrologContent()
Description copied from interface: Native
Returns the prolog content. It is the content generated before the child components, if any.

Default: empty ("").

Specified by:
getPrologContent in interface Native

setPrologContent

public void setPrologContent(java.lang.String prolog)
Description copied from interface: Native
Sets the prolog content. It is the content generated before the child components, if any.

Specified by:
setPrologContent in interface Native

getEpilogContent

public java.lang.String getEpilogContent()
Description copied from interface: Native
Returns the epilog content. It is the content generated before the child components, if any.

Default: empty ("").

Specified by:
getEpilogContent in interface Native

setEpilogContent

public void setEpilogContent(java.lang.String epilog)
Description copied from interface: Native
Sets the epilog content. It is the content generated before the child components, if any.

Specified by:
setEpilogContent in interface Native

getHelper

public Native.Helper getHelper()
Description copied from interface: Native
Returns the helper to generate the output of the native components.

Specified by:
getHelper in interface Native

setId

public void setId(java.lang.String id)
Description copied from interface: Component
Sets the ID. The scope of uniqueness depends on whether this component is a root component. Refer to Component.getId() for more details.

Default: "" (an empty string; it means no ID at all).

Specified by:
setId in interface Component
Overrides:
setId in class AbstractComponent
Parameters:
id - the identifier. You could specify null or an empty string to remove ID.
See Also:
Selectors

setVisible

public boolean setVisible(boolean visible)
Description copied from interface: Component
Sets whether this component is visible.

Specified by:
setVisible in interface Component
Overrides:
setVisible in class AbstractComponent
Returns:
the previous visibility

redraw

public void redraw(java.io.Writer out)
            throws java.io.IOException
Description copied from class: AbstractComponent
Redraws this component and all its descendants.

Default: It uses JsContentRenderer to render all information in JavaScript codes. For devices that don't support JavaScript, it must override this method.

To generate all information, it first invokes AbstractComponent.renderProperties(org.zkoss.zk.ui.sys.ContentRenderer) to render component's properties, and then AbstractComponent.redrawChildren(java.io.Writer) to redraw children (and descendants) (by calling their AbstractComponent.redraw(java.io.Writer)).

If a derived class wants to render more properties, it can override AbstractComponent.renderProperties(org.zkoss.zk.ui.sys.ContentRenderer).

If a derived class renders only a subset of its children (such as paging/cropping), it could override AbstractComponent.redrawChildren(java.io.Writer).

If a deriving class wants to do something before AbstractComponent.renderProperties(org.zkoss.zk.ui.sys.ContentRenderer), it has to override AbstractComponent.redraw(java.io.Writer).

If a deriving class doesn't want to render in JavaScript codes, it has to override AbstractComponent.redraw(java.io.Writer) with the proper implementation of ContentRenderer.

Specified by:
redraw in interface ComponentCtrl
Overrides:
redraw in class AbstractComponent
Throws:
java.io.IOException

renderProperties

protected void renderProperties(ContentRenderer renderer)
                         throws java.io.IOException
Description copied from class: AbstractComponent
Called by (ComponentCtrl.redraw(java.io.Writer)) to render the properties, excluding the enclosing tag and children.

Default: it renders AbstractComponent.getId() if it was assigned, and event names if listened (and listed in AbstractComponent.getClientEvents()).

Note: it doesn't render AbstractComponent.getWidgetClass(), AbstractComponent.getUuid() and AbstractComponent.getMold(), which are caller's job.

Overrides:
renderProperties in class AbstractComponent
Throws:
java.io.IOException

setTag

public void setTag(java.lang.String tag)
            throws WrongValueException
Sets the tag name.

Specified by:
setTag in interface DynamicTag
Parameters:
tag - the tag name. If null or empty, plain text is assumed.
Throws:
WrongValueException

hasTag

public boolean hasTag(java.lang.String tag)
Description copied from interface: DynamicTag
Returns whether the specified tag is allowed.

Specified by:
hasTag in interface DynamicTag

hasDynamicProperty

public boolean hasDynamicProperty(java.lang.String name)
Description copied from interface: DynamicPropertied
Returns whether a dynamic property is defined.

Specified by:
hasDynamicProperty in interface DynamicPropertied

getDynamicProperty

public java.lang.Object getDynamicProperty(java.lang.String name)
Description copied from interface: DynamicPropertied
Returns the property value of the specified name.

Specified by:
getDynamicProperty in interface DynamicPropertied

setDynamicProperty

public void setDynamicProperty(java.lang.String name,
                               java.lang.Object value)
                        throws WrongValueException
Description copied from interface: DynamicPropertied
Sets a property with the specified name and value.

If a component supports only String-type values, it could use org.zkoss.lang.Objects.toString() to convert the value to a String instance.

Specified by:
setDynamicProperty in interface DynamicPropertied
Throws:
WrongValueException

getExtraCtrl

public java.lang.Object getExtraCtrl()
Description copied from class: AbstractComponent
Returns the extra controls that tell ZK how to handle this component specially. It is used only by component developers.

Default: null.

Specified by:
getExtraCtrl in interface ComponentCtrl
Overrides:
getExtraCtrl in class AbstractComponent
Returns:
null if no special handling required. If the component requires some special controls, it could return an object that implements one or several interfaces in the org.zkoss.zk.ui.ext.render package. For example, Cropper.
See Also:
ComponentCtrl.getExtraCtrl()


Copyright © 2005-2011 Potix Corporation. All Rights Reserved. SourceForge.net Logo