org.zkoss.zul
Class Paging

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.Paging
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, HtmlBasedComponent, Component, Scope, ComponentCtrl, Paging, Pageable, Paginal, XulElement

public class Paging
extends XulElement
implements Paging, Paginal

Paging of long content.

Default getZclass(): z-paging. (since 3.5.0)

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
Paging()
           
Paging(int totalsz, int pagesz)
          Contructor.
 
Method Summary
 int getActivePage()
          Returns the active page (starting from 0).
 java.lang.String getInfoTags()
          Returns the HTML tags of paging information.
 java.lang.String getInnerTags()
          Returns the inner HTML tags of this component.
 java.lang.String getOuterAttrs()
          Returns the exterior attributes for generating the enclosing HTML tag; never return null.
 int getPageCount()
          Returns the number of pages.
 int getPageIncrement()
          Returns the number of page anchors shall appear at the client.
 int getPageSize()
          Returns the number of items per page.
 int getTotalSize()
          Returns the total number of items.
 java.lang.String getZclass()
          Returns the ZK Cascading Style class(es) for this component.
 void invalidate()
          Invalidates this component by setting the dirty flag such that it will be redraw the whole content later.
protected  void invalidateWholeIfAny()
           
 boolean isAutohide()
          Returns whether to automatically hide this component if there is only one page available.
 boolean isChildable()
          Default: return true (allows to have children).
 boolean isDetailed()
          Returns whether to show the detailed info, such as Paginal.getTotalSize().
 boolean isVisible()
          Returns whether this component is visible.
 void setActivePage(int pg)
          Sets the active page (starting from 0).
 void setAutohide(boolean autohide)
          Sets whether to automatically hide this component if there is only one page available.
 void setDetailed(boolean detailed)
          Sets whether to show the detailed info, such as Paginal.getTotalSize().
 void setPageIncrement(int pginc)
          Sets the number of page anchors shall appear at the client.
 void setPageSize(int size)
          Sets the number of items per page.
 void setTotalSize(int size)
          Sets the total number of items.
 void smartUpdate(java.lang.String attr, boolean value)
          A special smart-update that update a value in boolean.
 void smartUpdate(java.lang.String attr, int value)
          A special smart-update that update a value in int.
 void smartUpdate(java.lang.String attr, java.lang.String value)
          Smart-updates a property with the specified 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, redraw, 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, clone, containsVariable, detach, 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, 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, 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, redraw, removeAttribute, removeAttribute, removeChild, removeEventListener, removeForward, removeForward, setAttribute, setAttribute, setId, setMold, setPage, setPageBefore, setParent, setVariable, setVisible, unsetVariable
 
Methods inherited from interface org.zkoss.zul.ext.Paginal
addEventListener, removeEventListener
 

Constructor Detail

Paging

public Paging()

Paging

public Paging(int totalsz,
              int pagesz)
Contructor.

Parameters:
totalsz - the total # of items
pagesz - the # of items per page
Method Detail

smartUpdate

public void smartUpdate(java.lang.String attr,
                        java.lang.String value)
Description copied from interface: ComponentCtrl
Smart-updates a property with the specified value. Called by component developers to do precise-update.

The second invocation with the same property will replace the previous call. In other words, the same property will be set only once in each execution.

This method has no effect if Component.invalidate() is ever invoked (in the same execution), since Component.invalidate() assumes the whole content shall be redrawn and all smart updates to this components can be ignored,

Once this method is called, all invocations to ComponentCtrl.smartUpdate(java.lang.String, java.lang.String) will then be ignored, and Component.redraw(java.io.Writer) will be invoked later.

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

There are two ways to draw a component, one is to invoke Component.invalidate(), and the other is ComponentCtrl.smartUpdate(java.lang.String, java.lang.String). While Component.invalidate() causes the whole content to redraw, ComponentCtrl.smartUpdate(java.lang.String, java.lang.String) let component developer control which part to redraw.

Specified by:
smartUpdate in interface ComponentCtrl
Overrides:
smartUpdate in class AbstractComponent
value - the new value. If null, it means removing the property.
See Also:
ComponentCtrl.smartUpdateDeferred(java.lang.String, org.zkoss.zk.ui.util.DeferredValue), ComponentCtrl.smartUpdateValues(java.lang.String, java.lang.Object[])

smartUpdate

public void smartUpdate(java.lang.String attr,
                        int value)
Description copied from class: AbstractComponent
A special smart-update that update a value in int.

It will invoke AbstractComponent.smartUpdate(String,String) to update the attribute eventually.

Overrides:
smartUpdate in class AbstractComponent

smartUpdate

public void smartUpdate(java.lang.String attr,
                        boolean value)
Description copied from class: AbstractComponent
A special smart-update that update a value in boolean.

It will invoke AbstractComponent.smartUpdate(String,String) to update the attribute eventually.

Overrides:
smartUpdate in class AbstractComponent

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

invalidateWholeIfAny

protected void invalidateWholeIfAny()

getPageSize

public int getPageSize()
Description copied from interface: Pageable
Returns the number of items per page.

Default: 20.

Specified by:
getPageSize in interface Pageable

setPageSize

public void setPageSize(int size)
                 throws WrongValueException
Description copied from interface: Pageable
Sets the number of items per page.

Specified by:
setPageSize in interface Pageable
Throws:
WrongValueException

getTotalSize

public int getTotalSize()
Description copied from interface: Paginal
Returns the total number of items.

Specified by:
getTotalSize in interface Paginal

setTotalSize

public void setTotalSize(int size)
                  throws WrongValueException
Description copied from interface: Paginal
Sets the total number of items.

Specified by:
setTotalSize in interface Paginal
Throws:
WrongValueException

getPageCount

public int getPageCount()
Description copied from interface: Pageable
Returns the number of pages. Note: there is at least one page even no item at all.

Specified by:
getPageCount in interface Pageable

getActivePage

public int getActivePage()
Description copied from interface: Pageable
Returns the active page (starting from 0).

Specified by:
getActivePage in interface Pageable

setActivePage

public void setActivePage(int pg)
                   throws WrongValueException
Description copied from interface: Pageable
Sets the active page (starting from 0).

Specified by:
setActivePage in interface Pageable
Throws:
WrongValueException

getPageIncrement

public int getPageIncrement()
Description copied from interface: Paginal
Returns the number of page anchors shall appear at the client.

Default: 10.

Specified by:
getPageIncrement in interface Paginal

setPageIncrement

public void setPageIncrement(int pginc)
                      throws WrongValueException
Description copied from interface: Paginal
Sets the number of page anchors shall appear at the client.

Specified by:
setPageIncrement in interface Paginal
Throws:
WrongValueException

isDetailed

public boolean isDetailed()
Description copied from interface: Paginal
Returns whether to show the detailed info, such as Paginal.getTotalSize().

Specified by:
isDetailed in interface Paginal

setDetailed

public void setDetailed(boolean detailed)
Description copied from interface: Paginal
Sets whether to show the detailed info, such as Paginal.getTotalSize().

Specified by:
setDetailed in interface Paginal

isAutohide

public boolean isAutohide()
Returns whether to automatically hide this component if there is only one page available.

Default: false.

Specified by:
isAutohide in interface Paging

setAutohide

public void setAutohide(boolean autohide)
Sets whether to automatically hide this component if there is only one page available.

Specified by:
setAutohide in interface Paging

getInfoTags

public java.lang.String getInfoTags()
Returns the HTML tags of paging information.

Default: active-page-number / total-numbers-of-pages

Developers can override this method to show different information.

Since:
3.5.0

getInnerTags

public java.lang.String getInnerTags()
Returns the inner HTML tags of this component.

Used only for component development. Not accessible by application developers.

Since:
3.5.2

getZclass

public java.lang.String getZclass()
Description copied from class: HtmlBasedComponent
Returns the ZK Cascading Style class(es) for this component. It usually depends on the implementation of the mold (@{link #getMold}).

Default: null (the default value depends on element).

HtmlBasedComponent.setZclass(java.lang.String)) will completely replace the default style of a component. In other words, the default style of a component is associated with the default value of HtmlBasedComponent.getZclass(). Once it is changed, the default style won't be applied at all. If you want to perform small adjustments, use HtmlBasedComponent.setSclass(java.lang.String) instead.

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

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

isVisible

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

Specified by:
isVisible in interface Component
Overrides:
isVisible in class AbstractComponent
See Also:
Components.isRealVisible(org.zkoss.zk.ui.Component)

isChildable

public boolean isChildable()
Description copied from class: AbstractComponent
Default: return true (allows to have children).

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


Copyright © 2005-2009 Potix Corporation. All Rights Reserved.