Package org.zkoss.zul
Class Carousel
- java.lang.Object
-
- org.zkoss.zk.ui.AbstractComponent
-
- org.zkoss.zk.ui.HtmlBasedComponent
-
- org.zkoss.zul.impl.XulElement
-
- org.zkoss.zul.Carousel
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,org.zkoss.zk.ui.Component,org.zkoss.zk.ui.ext.Scope,org.zkoss.zk.ui.sys.ComponentCtrl
public class Carousel extends XulElement
A carousel (slideshow) container. Children must beCarouselitem.Default
getZclass(): "z-carousel".- Since:
- 10.4.0
- Author:
- yuehfeng
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Carousel()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidbeforeChildAdded(org.zkoss.zk.ui.Component child, org.zkoss.zk.ui.Component refChild)intgetActiveIndex()Returns the index of the currently active slide.java.lang.StringgetEffect()Returns the transition effect used when moving between slides.intgetInterval()Returns the autoplay interval in milliseconds.java.lang.StringgetOrient()Returns the orientation along which the slides advance.CarouselitemgetSelectedItem()Returns the currently active item, or null when there are no slides.java.lang.StringgetZclass()booleanisAutoplay()Returns whether the carousel advances through its slides automatically.booleanisKeyboard()Whether 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.booleanisShowArrows()Returns whether the previous/next navigation arrows are shown.booleanisShowIndicators()Returns whether the slide indicators (the position dots) are shown.voidonChildAdded(org.zkoss.zk.ui.Component child)voidonChildRemoved(org.zkoss.zk.ui.Component child)protected voidrenderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer)voidservice(org.zkoss.zk.au.AuRequest request, boolean everError)voidsetActiveIndex(int activeIndex)Sets the index of the currently active slide.voidsetAutoplay(boolean autoplay)Sets whether the carousel advances through its slides automatically.voidsetEffect(java.lang.String effect)Sets 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).voidsetOrient(java.lang.String orient)Sets 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, setTooltipAttributes
-
Methods inherited from class org.zkoss.zk.ui.HtmlBasedComponent
addSclass, evalCSSFlex, focus, getAction, getClientAction, getDraggable, getDroppable, getExtraCtrl, getHeight, getHflex, getLeft, getRenderdefer, getSclass, 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, setStyle, setTabindex, setTabindex, setTooltiptext, setTop, setTopDirectly, setVflex, setVflex0, setVflexDirectly, setWidth, setWidth0, setWidthDirectly, setZclass, setZindex, setZIndex, setZIndexDirectly
-
Methods 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, 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, 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
-
-
-
-
Method Detail
-
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 - 1for both render and getter so callers never observe an index that doesn't correspond to a real slide.
-
setActiveIndex
public void setActiveIndex(int activeIndex) throws org.zkoss.zk.ui.WrongValueExceptionSets the index of the currently active slide.- Parameters:
activeIndex- the zero-based index of the slide to activate; must be in[0, slideCount-1]. Setting a different value pushes the new value to the client viasmartUpdate.- Throws:
org.zkoss.zk.ui.WrongValueException- ifactiveIndexis negative, or is not less than the current number of slides.
-
isAutoplay
public boolean isAutoplay()
Returns whether the carousel advances through its slides automatically.Default: false.
- Since:
- 10.4.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:
- 10.4.0
-
setInterval
public void setInterval(int interval) throws org.zkoss.zk.ui.WrongValueExceptionSets the autoplay interval in milliseconds.- Throws:
org.zkoss.zk.ui.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:
- 10.4.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:
- 10.4.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:
- 10.4.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:
- 10.4.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:
- 10.4.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
public java.lang.String getOrient()
Returns the orientation along which the slides advance.Default: "horizontal".
- Since:
- 10.4.0
-
setOrient
public void setOrient(java.lang.String orient) throws org.zkoss.zk.ui.WrongValueExceptionSets the orientation along which the slides advance.- Parameters:
orient- one of "horizontal" or "vertical"; a null value is treated as "horizontal".- Throws:
org.zkoss.zk.ui.WrongValueException- iforientis neither "horizontal" nor "vertical".
-
getEffect
public java.lang.String getEffect()
Returns the transition effect used when moving between slides.Default: "slide".
- Since:
- 10.4.0
-
setEffect
public void setEffect(java.lang.String effect) throws org.zkoss.zk.ui.WrongValueExceptionSets the transition effect used when moving between slides.- Parameters:
effect- one of "slide", "fade" or "none"; a null value is treated as "slide".- Throws:
org.zkoss.zk.ui.WrongValueException- ifeffectis none of "slide", "fade" or "none".
-
getZclass
public java.lang.String getZclass()
- Overrides:
getZclassin classorg.zkoss.zk.ui.HtmlBasedComponent
-
renderProperties
protected void renderProperties(org.zkoss.zk.ui.sys.ContentRenderer renderer) throws java.io.IOException- Overrides:
renderPropertiesin classXulElement- Throws:
java.io.IOException
-
beforeChildAdded
public void beforeChildAdded(org.zkoss.zk.ui.Component child, org.zkoss.zk.ui.Component refChild)- Specified by:
beforeChildAddedin interfaceorg.zkoss.zk.ui.sys.ComponentCtrl- Overrides:
beforeChildAddedin classorg.zkoss.zk.ui.AbstractComponent
-
onChildAdded
public void onChildAdded(org.zkoss.zk.ui.Component child)
- Specified by:
onChildAddedin interfaceorg.zkoss.zk.ui.sys.ComponentCtrl- Overrides:
onChildAddedin classorg.zkoss.zk.ui.AbstractComponent
-
onChildRemoved
public void onChildRemoved(org.zkoss.zk.ui.Component child)
- Specified by:
onChildRemovedin interfaceorg.zkoss.zk.ui.sys.ComponentCtrl- Overrides:
onChildRemovedin classorg.zkoss.zk.ui.AbstractComponent
-
service
public void service(org.zkoss.zk.au.AuRequest request, boolean everError)- Specified by:
servicein interfaceorg.zkoss.zk.ui.sys.ComponentCtrl- Overrides:
servicein classorg.zkoss.zk.ui.HtmlBasedComponent
-
getSelectedItem
public Carouselitem 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.
-
-