|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.zkoss.zk.ui.AbstractComponent
org.zkoss.zk.ui.HtmlBasedComponent
org.zkoss.zul.impl.XulElement
org.zkoss.zul.Image
org.zkoss.zul.Captcha
public class Captcha
The generic captcha component.
Captcha requires an implementation of an engine (CaptchaEngine
).
The default engine is based on JHLabs and available in ZK PE and ZK EE.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.zkoss.zul.Image |
---|
Image.ExtraCtrl |
Nested classes/interfaces inherited from class org.zkoss.zk.ui.AbstractComponent |
---|
org.zkoss.zk.ui.AbstractComponent.Children |
Field Summary |
---|
Fields inherited from class org.zkoss.zk.ui.HtmlBasedComponent |
---|
_zclass |
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 | |
---|---|
Captcha()
|
Method Summary | |
---|---|
void |
addFont(Font font)
Add fonts into fonts list. |
String |
getBgColor()
Get the background color of the captcha box (in string as #RRGGBB). |
int |
getBgRGB()
Get the background color in int array (0: red, 1: green, 2:blue). |
CaptchaEngine |
getCaptchaEngine()
Get the captcha engine. |
Font[] |
getDefaultFonts()
Gets the default font list. |
String |
getExclude()
Get exclude characters. |
Font |
getFont(int j)
Get nth Font. |
String |
getFontColor()
Gets font color. |
int |
getFontRGB()
Get the font color in int array (0: red, 1: green, 2:blue). |
List<Font> |
getFonts()
Gets fonts list, default provide two fonts. |
int |
getIntHeight()
Get the captcha int height in pixel; to be used by the derived subclass. |
int |
getIntWidth()
Get the captcha int width in pixel; to be used by the derived subclass. |
int |
getLength()
Get length of the autogenerated text value; default to 5. |
String |
getValue()
Returns the text value of this captcha. |
boolean |
isBorder()
Deprecated. As of release 5.0.4, use isFrame() instead. |
boolean |
isFrame()
Returns whether generate border. |
boolean |
isNoise()
Returns whether generate noise; default to false. |
protected CaptchaEngine |
newCaptchaEngine()
Instantiates the default captcha engine. |
String |
randomValue()
Regenerates new captcha text value and redraw. |
void |
setBgColor(String color)
Set the background color of the chart. |
void |
setBorder(boolean b)
Deprecated. As of release 5.0.4, use setFrame(boolean) instead. |
void |
setEngine(CaptchaEngine engine)
Set the captcha engine. |
void |
setEngine(String clsnm)
Sets the captcha engine by use of a class name. |
void |
setExclude(String exclude)
Set exclude characters that will not be generated. |
void |
setFontColor(String color)
Set font color. |
void |
setFrame(boolean frame)
Sets whether generate border. |
void |
setHeight(String h)
Override super class to prepare the int height. |
void |
setLength(int len)
Set length of the autogenerated text value; default to 5. |
void |
setNoise(boolean b)
Sets whether generate noise; default to false. |
void |
setValue(String text)
Sets the text value to be shown as the distortion captcha. |
void |
setWidth(String w)
Override super class to prepare the int width. |
protected void |
smartDrawCaptcha()
mark a draw flag to inform that this Chart needs update. |
Methods inherited from class org.zkoss.zul.Image |
---|
getAlign, getBorder, getContent, getExtraCtrl, getHover, getHspace, getSrc, getVspace, isChildable, renderProperties, setAlign, setBorder, setContent, setContent, setHover, setHoverContent, setHoverContent, setHspace, setSrc, setVspace |
Methods inherited from class org.zkoss.zul.impl.XulElement |
---|
clone, getContext, getCtrlKeys, getPopup, getTooltip, setContext, setContext, setCtrlKeys, setPopup, setPopup, setTooltip, setTooltip |
Methods inherited from class org.zkoss.zk.ui.HtmlBasedComponent |
---|
focus, getAction, getDraggable, getDroppable, getHeight, getHflex, getLeft, getRenderdefer, getSclass, getStyle, getTooltiptext, getTop, getVflex, getWidth, getZclass, getZindex, getZIndex, service, setAction, setClass, setDraggable, setDroppable, setFocus, setHeightDirectly, setHflex, setHflexDirectly, setLeft, setLeftDirectly, setRenderdefer, setSclass, setStyle, setTooltiptext, setTop, setTopDirectly, setVflex, setWidthDirectly, setZclass, setZindex, setZIndex, setZIndexDirectly |
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, detach, didActivate, didActivate, didDeserialize, didDeserialize, disableClientUpdate, equals, getAnnotatedProperties, getAnnotatedPropertiesBy, getAnnotation, getAnnotation, getAnnotations, getAnnotations, getAttribute, getAttribute, getAttribute, getAttributeOrFellow, getAttributes, getAttributes, getAuService, getAutag, getChildren, getClientEvents, getDefaultMold, getDefinition, getDesktop, getEventHandler, getEventHandlerNames, getEventListeners, getFellow, getFellow, getFellowIfAny, getFellowIfAny, getFellows, getFirstChild, getId, getLastChild, getListenerIterator, getMold, getNextSibling, getPage, getParent, getPreviousSibling, getRoot, getSpaceOwner, getStubonly, getTemplate, getTemplateNames, getUuid, getWidgetAttribute, getWidgetAttributeNames, getWidgetClass, getWidgetListener, getWidgetListenerNames, getWidgetOverride, getWidgetOverrideNames, hasAttribute, hasAttribute, hasAttribute, hasAttributeOrFellow, hasFellow, hasFellow, insertBefore, invalidate, isInvalidated, isListenerAvailable, isVisible, onChildAdded, onChildRemoved, onPageAttached, onPageDetached, onWrongValue, redraw, redrawChildren, removeAttribute, removeAttribute, removeAttribute, removeChild, removeEventListener, removeForward, removeForward, removeScopeListener, render, render, render, replace, response, response, service, sessionDidActivate, sessionWillPassivate, setAttribute, setAttribute, setAttribute, setAuService, setAutag, setDefinition, setDefinition, setId, setMold, setPage, setPageBefore, setParent, setStubonly, setStubonly, setTemplate, setVisible, setVisibleDirectly, setWidgetAttribute, setWidgetClass, setWidgetListener, setWidgetOverride, smartUpdate, smartUpdate, 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 |
---|
public Captcha()
Method Detail |
---|
public List<Font> getFonts()
public Font[] getDefaultFonts()
public Font getFont(int j)
public void addFont(Font font)
public void setFontColor(String color)
public String getFontColor()
public int getFontRGB()
public void setBgColor(String color)
color
- in #RRGGBB format (hexdecimal).public String getBgColor()
public int getBgRGB()
public void setWidth(String w)
setWidth
in class org.zkoss.zk.ui.HtmlBasedComponent
public int getIntWidth()
public void setHeight(String h)
setHeight
in class org.zkoss.zk.ui.HtmlBasedComponent
public int getIntHeight()
public String getValue()
Default: an empty string.
Deriving class can override it to return whatever it wants other than null.
public void setValue(String text) throws org.zkoss.zk.ui.WrongValueException
text
- the captcha text value
org.zkoss.zk.ui.WrongValueException
public void setLength(int len)
public int getLength()
public void setExclude(String exclude)
public String getExclude()
public void setNoise(boolean b)
public boolean isNoise()
public void setBorder(boolean b)
setFrame(boolean)
instead.
Default to false.
public boolean isBorder()
isFrame()
instead.
Default to false.
public void setFrame(boolean frame)
Default to false.
public boolean isFrame()
Default to false.
public String randomValue()
public void setEngine(String clsnm) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InstantiationException, InvocationTargetException
ClassNotFoundException
NoSuchMethodException
IllegalAccessException
InstantiationException
InvocationTargetException
public void setEngine(CaptchaEngine engine)
public CaptchaEngine getCaptchaEngine() throws org.zkoss.zk.ui.UiException
org.zkoss.zk.ui.UiException
- if failed to load the engine.protected CaptchaEngine newCaptchaEngine() throws org.zkoss.zk.ui.UiException
setEngine(java.lang.String)
is not called with non-null
engine.
By default, it looks up the libarry property called
org.zkoss.zul.captcha.engine.class.
If found, the value is assumed to be
the class name of the captcha engine (it must implement
CaptchaEngine
.
If not found, UiException
is thrown.
Derived class might override this method to provide your own default class.
org.zkoss.zk.ui.UiException
- if failed to instantiate the engineprotected void smartDrawCaptcha()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |