zul.inp
Class InputWidget

java.lang.Object
  extended by zk.Object
      extended by zk.Widget
          extended by zul.Widget
              extended by zul.inp.InputWidget
Direct Known Subclasses:
ComboWidget, FormatWidget, Textbox

public class InputWidget
extends Widget

A skeletal implementation for a input widget.

The delay to send the onChanging event is controlled by onChangingDelay, which is default to 350. To change it, you can specify the following in a ZUL file.


<?script content="zk.afterLoad('zul.inp',function(){zul.inp.InputWidget.onChangingDelay=1000;})"?>


Field Summary
static int onChangingDelay
          The delay for sending the onChanging event (unit: milliseconds).
static boolean onChangingForced
          Whether to send at least one the onChanging event if it is listened and the content is ever changed.
 
Fields inherited from class zk.Widget
$weave, auDelay, autag, bindLevel, className, desktop, effects_, firstChild, id, insertingBefore_, inServer, lastChild, nChildren, nextSibling, parent, previousSibling, uuid, widgetName
 
Fields inherited from class zk.Object
$class, $oid
 
Method Summary
 void clearErrorMessage(boolean revalidate, boolean remainError)
          Clears the error message and the error status.
protected  String coerceFromString_(String value)
          Coerces the value passed to setValue(java.lang.Object, boolean).
protected  String coerceToString_(java.lang.Object value)
          Coerces the value passed to setValue(java.lang.Object, boolean).
 void fireOnChange(Map opts)
          Fires the onChange event.
 int getCols()
          Returns the cols.
 SimpleConstraint getConstraint()
          Returns the constraint, or null if no constraint at all.
 String getErrorMessage()
          Returns the error message that is caused when user entered invalid value, or null if no error at all.
 String getErrorMesssage()
          Deprecated. use getErrorMessage() instead.
 String getInplaceCSS()
          Returns the CSS style of inplace if inplace is not null
 DOMElement getInputNode()
          Returns the input node of this widget
 int getMaxlength()
          Returns the maxlength.
 String getName()
          Returns the name of this component.
 String getPlaceholder()
          Returns the placeholder text
 int getTabindex()
          Returns the tab order of this component.
 String getText()
          Returns the text representing the value in the given format, or an empty etring if value is null
 String getType()
          Returns the type.
 String getValue()
          Returns the value in the String format.
 boolean inRoundedMold()
          Returns whether is in rounded mold or not.
 boolean isDisabled()
          Returns whether it is disabled.
 boolean isInplace()
          Returns whether enable the inplace-editing.
 boolean isInstant()
          Returns whether to send onChange event as soon as user types in the input.
 boolean isMultiline()
          Returns whether it is multiline.
 boolean isReadonly()
          Returns whether it is readonly.
 void select(int start, int end)
          Selects the whole text in this input.
 void setCols(int cols)
          Sets the cols.
 void setConstraint(String cst)
          Sets the constraint.
 void setDisabled(boolean disabled)
          Sets whether it is disabled.
 void setErrorMessage(String msg)
          Marks this widget's value is wrong and show the error message.
 void setInplace(boolean inplace)
          Sets to enable the inplace-editing function that the look and feel is like a label.
 void setInstant(boolean instant)
          Sets whether to send onChange event as soon as user types in the input.
 void setMaxlength(int maxlength)
          Sets the maxlength.
 void setName(String name)
          Sets the name of this component.
 void setPlaceholder(String placeholder)
          Sets the placeholder text that is displayed when input is empty.
 void setReadonly(boolean readonly)
          Sets whether it is readonly.
 void setTabindex(int tabindex)
          Sets the tab order of this component.
 void setText(String txt)
          Sets the text representing the value in the given format.
 void setValue(java.lang.Object value, boolean fromServer)
          Sets the value in the String format(assumes no locale issue).
protected  void shallUpdate_(Widget focus)
          Returns shall be update or not
protected  void showError_(String msg)
          Create a Errorbox widget, and show the error message
protected  String textAttrs_()
          Attributes for the text control.
protected  boolean updateChange_()
          Updates the change to server by firing onChange if necessary.
protected  void validate_(java.lang.Object val)
          Make the SimpleConstraint calls the validate for val, if SimpleConstraint is exist
 
Methods inherited from class zul.Widget
afterKeyDown_, beforeCtrlKeys_, getContext, getCtrlKeys, getOpenTooltip, getPopup, getTooltip, setContext, setContext, setCtrlKeys, setPopup, setPopup, setTooltip, setTooltip
 
Methods inherited from class zk.Widget
$, $f, $f, $f, $init, $n, $n, $o, $s, afterAnima_, afterParentChanged_, appendChild, appendChild, beforeParentChanged_, beforeSendAU_, bind_, bind, bindChildren_, bindDoubleTap_, bindSwipe_, bindTapHold_, canActivate, cleanDrag_, clear, clearCache, cloneDrag_, deferRedraw_, deferRedrawHTML_, detach, doBlur_, doClick_, doDoubleClick_, doFocus_, doKeyDown_, doKeyPress_, doKeyUp_, domAttrs_, domClass_, domListen_, doMouseDown_, doMouseEnter_, doMouseLeave_, doMouseMove_, doMouseOut_, doMouseOver_, doMouseUp_, domStyle_, domTextStyleAttr_, domTooltiptext_, domUnlisten_, doResizeScroll_, doRightClick_, doSelect_, doSwipe_, doTooltipOut_, doTooltipOver_, dropEffect_, extraBind_, fire, fireX, focus_, focus, forcerender, fromPageCoord, get, getAction, getCaveNode, getChildAt, getChildIndex, getClass, getDraggable, getDragMessage_, getDragNode, getDragOptions_, getDrop_, getDroppable, getElementsById, getElementsByName, getFirstNode_, getFloatZIndex_, getHeight, getHflex, getId, getLeft, getMold, getOldWidget_, getPage, getRenderdefer, getSclass, getScrollLeft, getScrollTop, getStyle, getTextNode, getTooltiptext, getTop, getTopWidget, getVflex, getWidth, getZclass, getZIndex, hide, ignoreDescendantFloatUp_, ignoreDrag_, initDrag_, insertBefore, insertChildHTML_, isAutoId, isBinding, isFloating_, isListen, isRealElement, isRealVisible, isRealVisible, isVisible, isVisible, isWatchable_, listen, listenOnFitSize_, mimicMouseDown_, newInstance, nextUuid, onAfterSize, onChildAdded_, onChildRemoved_, onChildRenderDefer_, onChildReplaced_, onChildVisible_, onDrop_, redraw, redrawHTML_, register, removeChild, removeChild, removeChildHTML_, removeHTML_, replaceCavedChildren_, replaceChildHTML_, replaceHTML, replaceWidget, rerender, rerender, scrollIntoView, sendAU_, set, set, setAction, setChildren, setDomVisible_, setDraggable, setDroppable, setFloating_, setFloatZIndex_, setHeight, setHflex, setId, setLeft, setListener, setListener, setListeners, setMold, setRenderdefer, setSclass, setScrollLeft, setScrollTop, setStyle, setTooltiptext, setTop, setTopmost, setVflex, setVisible, setWidth, setZclass, setZIndex, shallChildROD_, shallIgnoreClick_, show, smartUpdate, unbind_, unbind, unbindChildren_, unbindDoubleTap_, unbindSwipe_, unbindTapHold_, uncloneDrag_, unlisten, unlistenOnFitSize_, updateDomClass_, updateDomStyle_, uuid, zsync
 
Methods inherited from class zk.Object
$init, $instanceof, $super, $super, $supers, $supers, afterInit, isAssignableFrom, isInstance, proxy
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

onChangingDelay

public static int onChangingDelay
The delay for sending the onChanging event (unit: milliseconds). The onChanging event will be sent after the specified delay once the user pressed a keystroke (and changed the value).

Default: 350

Since:
5.0.1

onChangingForced

public static boolean onChangingForced
Whether to send at least one the onChanging event if it is listened and the content is ever changed.

Default: true

Since:
5.0.1
Method Detail

setName

public void setName(String name)
Sets the name of this component.

Don't use this method if your application is purely based on ZK's event-driven model.

The name is used only to work with "legacy" Web application that handles user's request by servlets. It works only with HTTP/HTML-based browsers. It doesn't work with other kind of clients.

Parameters:
name - the name of this component.

getName

public String getName()
Returns the name of this component.

Default: null.

Don't use this method if your application is purely based on ZK's event-driven model.

The name is used only to work with "legacy" Web application that handles user's request by servlets. It works only with HTTP/HTML-based browsers. It doesn't work with other kind of clients.

Returns:
String

setDisabled

public void setDisabled(boolean disabled)
Sets whether it is disabled.

Parameters:
disabled -

isDisabled

public boolean isDisabled()
Returns whether it is disabled.

Default: false.

Returns:
boolean

setReadonly

public void setReadonly(boolean readonly)
Sets whether it is readonly.

Parameters:
readonly -

isReadonly

public boolean isReadonly()
Returns whether it is readonly.

Default: false.

Returns:
boolean

setCols

public void setCols(int cols)
Sets the cols.

Parameters:
cols -

getCols

public int getCols()
Returns the cols.

Default: 0 (non-positive means the same as browser's default).

Returns:
int

setMaxlength

public void setMaxlength(int maxlength)
Sets the maxlength.

Parameters:
maxlength -

getMaxlength

public int getMaxlength()
Returns the maxlength.

Default: 0 (non-postive means unlimited).

Returns:
int

setTabindex

public void setTabindex(int tabindex)
Sets the tab order of this component.

Parameters:
tabindex -

getTabindex

public int getTabindex()
Returns the tab order of this component.

Default: 0 (means the same as browser's default).

Returns:
int

setInplace

public void setInplace(boolean inplace)
Sets to enable the inplace-editing function that the look and feel is like a label.

Parameters:
inplace -

isInplace

public boolean isInplace()
Returns whether enable the inplace-editing.

default: false.

Returns:
boolean

setPlaceholder

public void setPlaceholder(String placeholder)
Sets the placeholder text that is displayed when input is empty. Only works for browsers supporting HTML5.

Parameters:
placeholder -
Since:
6.5.0

getPlaceholder

public String getPlaceholder()
Returns the placeholder text

Returns:
String placeholder
Since:
6.5.0

setInstant

public void setInstant(boolean instant)
Sets whether to send onChange event as soon as user types in the input.

Parameters:
instant -
Since:
6.0.0

isInstant

public boolean isInstant()
Returns whether to send onChange event as soon as user types in the input.

Default: false.

Returns:
boolean
Since:
6.0.0

getInplaceCSS

public String getInplaceCSS()
Returns the CSS style of inplace if inplace is not null

Returns:
String

select

public void select(int start,
                   int end)
Selects the whole text in this input.

Parameters:
start - the starting index of the selection range
end - the ending index of the selection range (excluding). In other words, the text between start and (end-1) is selected.

getType

public String getType()
Returns the type.

Default: text.

Returns:
String

isMultiline

public boolean isMultiline()
Returns whether it is multiline.

Default: false.

Returns:
boolean

inRoundedMold

public boolean inRoundedMold()
Returns whether is in rounded mold or not.

Default: false, only combo component are true (@since 7.0.0)

Returns:
boolean

getText

public String getText()
Returns the text representing the value in the given format, or an empty etring if value is null

Returns:
String
Since:
5.0.5

setText

public void setText(String txt)
Sets the text representing the value in the given format.

Parameters:
txt - the text
Since:
5.0.5

getValue

public String getValue()
Returns the value in the String format.

Returns:
String

setValue

public void setValue(java.lang.Object value,
                     boolean fromServer)
Sets the value in the String format(assumes no locale issue).

Notice that the invocation of getValue() won't fire the onChange event. To fire it, you have to invoke fireOnChange(_global_.Map) explicitly.

Parameters:
value - the value.
fromServer - whether it is called from the server. The error message will be cleared if true

textAttrs_

protected String textAttrs_()
Attributes for the text control. Called automatically by [[#domAttrs_]] unless {text:true} is specified

Returns:
String

setConstraint

public void setConstraint(String cst)
Sets the constraint.

Default: null (means no constraint all all).

Parameters:
cst -

getConstraint

public SimpleConstraint getConstraint()
Returns the constraint, or null if no constraint at all.

Returns:
zul.inp.SimpleConstraint

shallUpdate_

protected void shallUpdate_(Widget focus)
Returns shall be update or not

Parameters:
focus -

getErrorMesssage

public String getErrorMesssage()
Deprecated. use getErrorMessage() instead.

Returns the error message that is caused when user entered invalid value, or null if no error at all.

The error message is set when user has entered a wrong value, or setValue is called with a wrong value. It is cleared once a correct value is assigned.

If the error message is set, we say this input is in the error mode.

Returns:
String

getErrorMessage

public String getErrorMessage()
Returns the error message that is caused when user entered invalid value, or null if no error at all.

The error message is set when user has entered a wrong value, or setValue is called with a wrong value. It is cleared once a correct value is assigned.

If the error message is set, we say this input is in the error mode.

Returns:
String

setErrorMessage

public void setErrorMessage(String msg)
Marks this widget's value is wrong and show the error message.

It is usually called by AuCmd0.wrongValue(zk.Object...) (from the sever)

Parameters:
msg - the error message

clearErrorMessage

public void clearErrorMessage(boolean revalidate,
                              boolean remainError)
Clears the error message and the error status.

It is also called by AuCmd0.clearWrongValue(_global_.String...) (from the server).

Parameters:
revalidate - whether to re-validate the value next time onblur occurs
remainError - whether the input widget remains in the error status, if any, after the invocation.

coerceFromString_

protected String coerceFromString_(String value)
Coerces the value passed to setValue(java.lang.Object, boolean).

Deriving note:
If you want to store the value in other type, say BigDecimal, you have to override coerceToString_(java.lang.Object) and coerceFromString_(_global_.String) to convert between a string and your targeting type.

Moreover, when Textbox is called, it calls this method with value = null. Derives shall handle this case properly.

Parameters:
value - the string to coerce from
Returns:
String

coerceToString_

protected String coerceToString_(java.lang.Object value)
Coerces the value passed to setValue(java.lang.Object, boolean).

Default: convert null to an empty string.

Deriving note:
If you want to store the value in other type, say BigDecimal, you have to override coerceToString_(java.lang.Object) and coerceFromString_(_global_.String) to convert between a string and your targeting type.

Parameters:
value - the value that will be coerced to a string
Returns:
String

validate_

protected void validate_(java.lang.Object val)
Make the SimpleConstraint calls the validate for val, if SimpleConstraint is exist

Parameters:
val - a String, a number, or a date,the number or name of flag, such as 'no positive", 0x0001.

showError_

protected void showError_(String msg)
Create a Errorbox widget, and show the error message

Parameters:
msg - the error message
See Also:
Errorbox.show()

updateChange_

protected boolean updateChange_()
Updates the change to server by firing onChange if necessary.

Returns:
boolean

fireOnChange

public void fireOnChange(Map opts)
Fires the onChange event. If the widget is created at the server, the event will be sent to the server too.

Parameters:
opts - [optional] the options. Refer to Event.opts
Since:
5.0.5

getInputNode

public DOMElement getInputNode()
Returns the input node of this widget

Returns:
DOMElement


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