Class Carousel
- All Implemented Interfaces:
Serializable,Cloneable,Component,Scope,ComponentCtrl
Carouselitem.
Default getZclass(): "z-carousel".
- Since:
- 11.0.0
- Author:
- yuehfeng
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.zkoss.zk.ui.HtmlBasedComponent
HtmlBasedComponent.ExtraCtrlNested classes/interfaces inherited from class org.zkoss.zk.ui.AbstractComponent
AbstractComponent.Children, AbstractComponent.ForwardInfo, AbstractComponent.TargetInfo -
Field Summary
Fields inherited from class org.zkoss.zk.ui.HtmlBasedComponent
_zclassFields inherited from interface org.zkoss.zk.ui.Component
APPLICATION_SCOPE, COMPONENT_SCOPE, DESKTOP_SCOPE, PAGE_SCOPE, REQUEST_SCOPE, SESSION_SCOPE, SPACE_SCOPEFields inherited from interface org.zkoss.zk.ui.sys.ComponentCtrl
AFTER_CHILD_ADDED, AFTER_CHILD_REMOVED, AFTER_CLONED, AFTER_PAGE_ATTACHED, AFTER_PAGE_DETACHED, AFTER_PARENT_CHANGED, CE_BUSY_IGNORE, CE_DUPLICATE_IGNORE, CE_IMPORTANT, CE_NON_DEFERRABLE, CE_REPEAT_IGNORE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidbeforeChildAdded(Component child, Component refChild) Default: does nothing.intReturns the index of the currently active slide.Returns the transition effect used when moving between slides.intReturns the autoplay interval in milliseconds.Returns the orientation along which the slides advance.Returns the currently active item, or null when there are no slides.Returns the ZK Cascading Style class for this component.booleanReturns whether the carousel advances through its slides automatically.booleanWhether the carousel reacts to left/right arrow keys when focused.booleanisLoop()Returns whether the carousel wraps around from the last slide back to the first (and vice versa).booleanisPause()Whether autoplay pauses while the cursor hovers over the carousel.booleanReturns whether the previous/next navigation arrows are shown.booleanReturns whether the slide indicators (the position dots) are shown.voidonChildAdded(Component child) Default: handles special event listeners.voidonChildRemoved(Component child) Default: handles special event listeners.protected voidrenderProperties(ContentRenderer renderer) Renders the content of this component, excluding the enclosing tags and children.voidProcesses an AU request.voidsetActiveIndex(int activeIndex) Sets the index of the currently active slide.voidsetAutoplay(boolean autoplay) Sets whether the carousel advances through its slides automatically.voidSets the transition effect used when moving between slides.voidsetInterval(int interval) Sets the autoplay interval in milliseconds.voidsetKeyboard(boolean keyboard) Sets whether the carousel reacts to left/right arrow keys when focused.voidsetLoop(boolean loop) Sets whether the carousel wraps around from the last slide back to the first (and vice versa).voidSets the orientation along which the slides advance.voidsetPause(boolean pause) Sets whether autoplay pauses while the cursor hovers over the carousel.voidsetShowArrows(boolean showArrows) Sets whether the previous/next navigation arrows are shown.voidsetShowIndicators(boolean showIndicators) Sets whether the slide indicators (the position dots) are shown.Methods inherited from class org.zkoss.zul.impl.XulElement
clone, getContext, getCtrlKeys, getPopup, getPropertyAccess, getTooltip, setContext, setContext, setContextAttributes, setCtrlKeys, setPopup, setPopup, setPopupAttributes, setTooltip, setTooltip, setTooltipAttributesMethods inherited from class org.zkoss.zk.ui.HtmlBasedComponent
addSclass, evalCSSFlex, focus, getAction, getClientAction, getDraggable, getDroppable, getExtraCtrl, getHeight, getHflex, getLeft, getRenderdefer, getSclass, getSkeleton, getStyle, getTabindex, getTabindexInteger, getTooltiptext, getTop, getVflex, getWidth, getZindex, getZIndex, removeSclass, removeSclass, setAction, setClass, setClientAction, setDraggable, setDroppable, setFocus, setHeight, setHeight0, setHeightDirectly, setHflex, setHflex0, setHflexDirectly, setLeft, setLeftDirectly, setRenderdefer, setSclass, setSkeleton, setStyle, setTabindex, setTabindex, setTooltiptext, setTop, setTopDirectly, setVflex, setVflex0, setVflexDirectly, setWidth, setWidth0, setWidthDirectly, setZclass, setZindex, setZIndex, setZIndexDirectlyMethods inherited from class org.zkoss.zk.ui.AbstractComponent
addAnnotation, addCallback, addClientEvent, addEventHandler, addEventListener, addEventListener, addForward, addForward, addForward, addForward, addMoved, addRedrawCallback, addScopeListener, addShadowRoot, addShadowRootBefore, addSharedEventHandlerMap, appendChild, applyProperties, beforeChildRemoved, beforeParentChanged, destroyIndexCacheMap, detach, didActivate, didActivate, didDeserialize, didDeserialize, disableBindingAnnotation, disableClientUpdate, disableHostChanged, enableBindingAnnotation, enableHostChanged, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotations, getAnnotations, getAttribute, getAttribute, getAttribute, getAttributeOrFellow, getAttributes, getAttributes, getAuService, getAutag, getCallback, getChildren, getClientAttribute, getClientDataAttribute, getClientEvents, getDefaultMold, getDefinition, getDesktop, getEventHandler, getEventHandlerNames, getEventListenerMap, getEventListeners, getFellow, getFellow, getFellowIfAny, getFellowIfAny, getFellows, getFirstChild, getForwards, getId, getIndexCacheMap, getLastChild, getMold, getNextSibling, getPage, getParent, getPreviousSibling, getRedrawCallback, getRoot, getShadowFellowIfAny, getShadowRoots, getShadowVariable, getShadowVariable, getShadowVariable0, getSpaceOwner, getSpecialRendererOutput, getStubonly, getStubonlyDescendants, getSubBindingAnnotationCount, getTemplate, getTemplateNames, getUuid, getWidgetAttributeNames, getWidgetClass, getWidgetListener, getWidgetListenerNames, getWidgetOverride, getWidgetOverrideNames, hasAttribute, hasAttribute, hasAttribute, hasAttributeOrFellow, hasBindingAnnotation, hasFellow, hasFellow, hasSubBindingAnnotation, initIndexCacheMap, insertBefore, invalidate, isChildable, isDisabledHostChanged, isInitialized, isInvalidated, isListenerAvailable, isVisible, onPageAttached, onPageDetached, onParentChanged, onWrongValue, query, queryAll, redraw, redrawChildren, removeAttribute, removeAttribute, removeAttribute, removeCallback, removeChild, removeEventListener, removeForward, removeForward, removeRedrawCallback, removeScopeListener, removeShadowRoot, render, render, render, renderPropertiesOnly, replace, response, response, response, service, sessionDidActivate, sessionWillPassivate, setAttribute, setAttribute, setAttribute, setAuService, setAutag, setClientAttribute, setClientDataAttribute, setDefinition, setDefinition, setId, setMold, setPage, setPageBefore, setParent, setStubonly, setStubonly, setStubonlyDescendants, setSubBindingAnnotationCount, setTemplate, setVisible, setVisibleDirectly, setWidgetClass, setWidgetListener, setWidgetOverride, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdate, smartUpdateWidgetListener, smartUpdateWidgetOverride, toString, updateByClient, updateSubBindingAnnotationCount, willPassivate, willPassivate, willSerialize, willSerialize
-
Constructor Details
-
Carousel
public Carousel()
-
-
Method Details
-
getActiveIndex
public int getActiveIndex()Returns the index of the currently active slide.Matches what
renderProperties(org.zkoss.zk.ui.sys.ContentRenderer)actually sends to the client: when the stored_activeIndexexceeds the current child count (e.g. ZUL setactiveIndex='5'before adding children), the value is clamped tocount - 1— or 0 when there are no slides — for both render and getter so callers never observe an index that doesn't correspond to a real slide. -
setActiveIndex
Sets the index of the currently active slide.- Parameters:
activeIndex- the zero-based index of the slide to activate; must be in[0, slideCount-1]once the carousel has rendered. Setting a different value pushes the new value to the client viasmartUpdate.- Throws:
WrongValueException- if the carousel has already rendered andactiveIndexis outside[0, slideCount-1]. Before the first render the value is stored unchecked, because a ZUL page may set it above the carousel's owncarouselitemchildren.
-
isAutoplay
public boolean isAutoplay()Returns whether the carousel advances through its slides automatically.Default: false.
- Since:
- 11.0.0
-
setAutoplay
public void setAutoplay(boolean autoplay) Sets whether the carousel advances through its slides automatically.- Parameters:
autoplay- true to start advancing slides automatically (using theinterval), false to leave navigation manual.
-
getInterval
public int getInterval()Returns the autoplay interval in milliseconds.Default: 5000.
- Since:
- 11.0.0
-
setInterval
Sets the autoplay interval in milliseconds.- Throws:
WrongValueException- ifintervalis less than 500ms — the animation cannot reliably finish (and screen readers cannot announce the slide change) inside a tighter window.
-
isShowArrows
public boolean isShowArrows()Returns whether the previous/next navigation arrows are shown.Default: true.
- Since:
- 11.0.0
-
setShowArrows
public void setShowArrows(boolean showArrows) Sets whether the previous/next navigation arrows are shown.- Parameters:
showArrows- true to display the navigation arrows, false to hide them.
-
isShowIndicators
public boolean isShowIndicators()Returns whether the slide indicators (the position dots) are shown.Default: true.
- Since:
- 11.0.0
-
setShowIndicators
public void setShowIndicators(boolean showIndicators) Sets whether the slide indicators (the position dots) are shown.- Parameters:
showIndicators- true to display the indicators, false to hide them.
-
isLoop
public boolean isLoop()Returns whether the carousel wraps around from the last slide back to the first (and vice versa).Default: true.
- Since:
- 11.0.0
-
setLoop
public void setLoop(boolean loop) Sets whether the carousel wraps around from the last slide back to the first (and vice versa).- Parameters:
loop- true to wrap around continuously, false to stop at the ends.
-
isPause
public boolean isPause()Whether autoplay pauses while the cursor hovers over the carousel. Mirrors Bootstrap'sdata-bs-pause="hover"behavior.Default: true.
- Since:
- 11.0.0
-
setPause
public void setPause(boolean pause) Sets whether autoplay pauses while the cursor hovers over the carousel.- Parameters:
pause- true to pause autoplay on hover, false to keep advancing.
-
isKeyboard
public boolean isKeyboard()Whether the carousel reacts to left/right arrow keys when focused. Mirrors Bootstrap'skeyboardoption.Default: true.
- Since:
- 11.0.0
-
setKeyboard
public void setKeyboard(boolean keyboard) Sets whether the carousel reacts to left/right arrow keys when focused.- Parameters:
keyboard- true to enable arrow-key navigation, false to disable it.
-
getOrient
Returns the orientation along which the slides advance.Default: "horizontal".
- Since:
- 11.0.0
-
setOrient
Sets the orientation along which the slides advance.- Parameters:
orient- one of "horizontal" or "vertical"; a null value is treated as "horizontal".- Throws:
WrongValueException- iforientis neither "horizontal" nor "vertical".
-
getEffect
Returns the transition effect used when moving between slides.Default: "slide".
- Since:
- 11.0.0
-
setEffect
Sets the transition effect used when moving between slides.- Parameters:
effect- one of "slide", "fade" or "none"; a null value is treated as "slide".- Throws:
WrongValueException- ifeffectis none of "slide", "fade" or "none".
-
getZclass
Description copied from class:HtmlBasedComponentReturns the ZK Cascading Style class for this component. It usually depends on the implementation of the mold (AbstractComponent.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 ofHtmlBasedComponent.getZclass(). Once it is changed, the default style won't be applied at all. If you want to perform small adjustments, useHtmlBasedComponent.setSclass(java.lang.String)instead.- Overrides:
getZclassin classHtmlBasedComponent- See Also:
-
renderProperties
Description copied from class:HtmlBasedComponentRenders the content of this component, excluding the enclosing tags and children.- Overrides:
renderPropertiesin classXulElement- Throws:
IOException
-
beforeChildAdded
Description copied from class:AbstractComponentDefault: does nothing.- Specified by:
beforeChildAddedin interfaceComponentCtrl- Overrides:
beforeChildAddedin classAbstractComponent- Parameters:
child- the child to be added (never null).refChild- another child component that the new child will be inserted before it. If null, the new child will be the last child.- See Also:
-
onChildAdded
Description copied from class:AbstractComponentDefault: handles special event listeners.- Specified by:
onChildAddedin interfaceComponentCtrl- Overrides:
onChildAddedin classAbstractComponent- See Also:
-
onChildRemoved
Description copied from class:AbstractComponentDefault: handles special event listeners.- Specified by:
onChildRemovedin interfaceComponentCtrl- Overrides:
onChildRemovedin classAbstractComponent- See Also:
-
service
Description copied from class:HtmlBasedComponentProcesses an AU request.Default: it handles onClick, onDoubleClick, onRightClick onMove, onSize, onZIndex.
- Specified by:
servicein interfaceComponentCtrl- Overrides:
servicein classHtmlBasedComponenteverError- whether any error ever occurred before processing this request.- See Also:
-
getSelectedItem
Returns the currently active item, or null when there are no slides.The lookup uses the same clamped index as
getActiveIndex()so the two getters stay in agreement when_activeIndexwas set out of range before any child was attached.
-