| org.zkoss.zul.impl.XulElement org.zkoss.zul.impl.InputElement
All known Subclasses: org.zkoss.zul.Timebox, org.zkoss.zul.Textbox, org.zkoss.zul.impl.FormatInputElement,
InputElement | abstract public class InputElement extends XulElement implements Constrainted(Code) | | A skeletal implementation of an input box.
Events: onChange, onChanging, onFocus, onBlur, onSelection, and onOK
Default
InputElement.getSclass : text.
author: tomyeh since: 3.0.1 supports onOK event. |
Method Summary | |
protected void | checkUserError() Checks whether user entered a wrong value (and not correct it yet). | public void | clearErrorMessage(boolean revalidateRequired) Clears the error message.
The error message is cleared automatically, so you rarely need
to call this method.
However, if a constraint depends on multiple input fields and
the error can be corrected by changing one of these fields,
then you may have to clear the error message manullay by invoking
this method.
For example, assume you have two
org.zkoss.zul.Intbox and want the value of the first one to be smaller than that of the
second one. | public void | clearErrorMessage() Clears the error message.
It is the same as clearErrorMessage(false). | abstract protected Object | coerceFromString(String value) Coerces the value passed to
InputElement.setText .
Deriving note:
If you want to store the value in other type, say BigDecimal,
you have to override
InputElement.coerceToString and
InputElement.coerceFromString to convert between a string and your targeting type.
Moreover, when
org.zkoss.zul.Textbox is called, it calls this method
with value = null. | abstract protected String | coerceToString(Object value) Coerces the value passed to
InputElement.setText . | public String | getAreaText() Returns the text for HTML AREA (Internal Use Only).
Used only for component generation. | public int | getCols() Returns the cols. | final public Constraint | getConstraint() | public String | getErrorMessage() Returns the error message that is caused when user entered
invalid value, or null if no error at all. | public String | getInnerAttrs() | public int | getMaxlength() Returns the maxlength. | 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. | public String | getOuterAttrs() | public String | getRawText() Returns the text directly without checking whether any error
message not yet fixed. | public Object | getRawValue() Returns the raw value directly with checking whether any
error message not yet fixed. | public int | getTabindex() Returns the tab order of this component. | protected Object | getTargetValue() Returns the value in the targeting type. | public String | getText() Returns the value in the String format. | public String | getType() Returns the type. | protected boolean | isAsapRequired(String evtnm) Returns whether to send back the request of the specified event
immediately -- non-deferable. | public boolean | isChildable() Not childable. | public boolean | isDisabled() Returns whether it is disabled. | public boolean | isMultiline() Returns whether it is multiline. | public boolean | isReadonly() Returns whether it is readonly. | public boolean | isValid() Returns the current content of this input is correct. | protected Object | newExtraCtrl() | public WrongValueException | onWrongValue(WrongValueException ex) | public void | select() Selects the whole text in this input. | public void | setCols(int cols) Sets the cols. | public void | setConstraint(String constr) | public void | setConstraint(Constraint constr) | public void | setDisabled(boolean disabled) Sets whether it is disabled. | public void | setMaxlength(int maxlength) Sets the maxlength. | 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. | public void | setRawValue(Object value) Sets the raw value directly. | public void | setReadonly(boolean readonly) Sets whether it is readonly. | public void | setSelectedText(int start, int end, String newtxt, boolean isHighLight) Sets the text of this InputElement to the specified text which is
begining with the new start point and ending with the new end point. | public void | setSelectionRange(int start, int end) Sets the selection end to the specified position and the selection start
to the specified position. | public void | setTabindex(int tabindex) Sets the tab order of this component. | public void | setText(String value) Sets the value in the String format. | protected void | setValueDirectly(Object value) Sets the value directly. | protected WrongValueException | showCustomError(WrongValueException ex) Shows the error message in the custom way by calling
(
CustomConstraint.showCustomError , if the contraint
implements
CustomConstraint .
Derived class shall call this method before throwing
WrongValueException , such that the constraint,
if any, has a chance to show the error message in a custom way.
Parameters: ex - the exception, or null to clean up the error. | protected void | validate(Object value) Validates the value returned by
InputElement.coerceFromString . |
InputElement | public InputElement()(Code) | | |
clearErrorMessage | public void clearErrorMessage(boolean revalidateRequired)(Code) | | Clears the error message.
The error message is cleared automatically, so you rarely need
to call this method.
However, if a constraint depends on multiple input fields and
the error can be corrected by changing one of these fields,
then you may have to clear the error message manullay by invoking
this method.
For example, assume you have two
org.zkoss.zul.Intbox and want the value of the first one to be smaller than that of the
second one. Then, you have to call this method for the second intbox
once the validation of the first intbox succeeds, and vice versa.
Otherwise, the error message for the seoncd intbox remains if
the user fixed the error by lowering down the value of the first one
Why? The second intbox got no idea to clear the error message
(since its content doesn't change).
Parameters: revalidateRequired - whether to re-validate the current valuewhen InputElement.getText or others (such as org.zkoss.zul.Intbox.getValue)is called.If false, the current value is assumed to be correct andthe following invocation to InputElement.getText or others (such as org.zkoss.zul.Intbox.getValue)won't check the value again.Note: when an input element is constrcuted, the initial valueis assumed to be "not-validated-yet". since: 3.0.1 |
getAreaText | public String getAreaText()(Code) | | Returns the text for HTML AREA (Internal Use Only).
Used only for component generation. Not for applications.
|
getCols | public int getCols()(Code) | | Returns the cols.
Default: 0 (non-positive means the same as browser's default).
|
getErrorMessage | public String getErrorMessage()(Code) | | 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.
Any following invocation to
InputElement.getText or getValue will throw
any exception.
Example,
org.zkoss.zul.Textbox.getValue and
org.zkoss.zul.Intbox.getValue .
|
getMaxlength | public int getMaxlength()(Code) | | Returns the maxlength.
Default: 0 (non-postive means unlimited).
|
getName | public String getName()(Code) | | 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.
|
getTabindex | public int getTabindex()(Code) | | Returns the tab order of this component.
Default: -1 (means the same as browser's default).
|
getType | public String getType()(Code) | | Returns the type.
Default: text.
|
isAsapRequired | protected boolean isAsapRequired(String evtnm)(Code) | | Returns whether to send back the request of the specified event
immediately -- non-deferable.
Returns true if you want the component (on the server)
to process the event immediately.
Default: Besides super.isAsapRequired(evtnm), it also returns true
if evtnm is Events.ON_CHANGE,
InputElement.getConstraint is not null,
and
ClientConstraint.getClientValidation is null.
|
isChildable | public boolean isChildable()(Code) | | Not childable.
|
isDisabled | public boolean isDisabled()(Code) | | Returns whether it is disabled.
Default: false.
|
isMultiline | public boolean isMultiline()(Code) | | Returns whether it is multiline.
Default: false.
|
isReadonly | public boolean isReadonly()(Code) | | Returns whether it is readonly.
Default: false.
|
isValid | public boolean isValid()(Code) | | Returns the current content of this input is correct.
If the content is not correct, next call to the getvalue method will
throws WrongValueException.
|
select | public void select()(Code) | | Selects the whole text in this input.
|
setDisabled | public void setDisabled(boolean disabled)(Code) | | Sets whether it is disabled.
|
setMaxlength | public void setMaxlength(int maxlength)(Code) | | Sets the maxlength.
|
setName | public void setName(String name)(Code) | | 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. |
setRawValue | public void setRawValue(Object value)(Code) | | Sets the raw value directly. The caller must make sure the value
is correct (or intend to be incorrect), because this method
doesn't do any validation.
If you feel confusing with setValue, such as
org.zkoss.zul.Textbox.setValue ,
it is usually better to use setValue instead. This method
is reserved for developer that really want to set an 'illegal'
value (such as an empty string to a textbox with no-empty contraint).
Note: since 3.0.1, the value will be re-validate again if
InputElement.getText or others (such as
org.zkoss.zul.Intbox.getValue )
is called. In other words, it is assumed that the specified value
is not validated yet -- the same state when this component is
created. If you want to avoid the re-valiation, you have to invoke
InputElement.clearErrorMessage() .
Like setValue, the result is returned back to the server
by calling
InputElement.getText .
See Also: InputElement.getRawValue |
setReadonly | public void setReadonly(boolean readonly)(Code) | | Sets whether it is readonly.
|
setSelectedText | public void setSelectedText(int start, int end, String newtxt, boolean isHighLight)(Code) | | Sets the text of this InputElement to the specified text which is
begining with the new start point and ending with the new end point.
Parameters: start - the start position of the text (included) Parameters: end - the end position of the text (excluded) Parameters: newtxt - the new text to be set. Parameters: isHighLight - Sets whether it will represent highlihgt style or cursorstyle.If the start point same with the end point alwaysrepresent cursor style. |
setSelectionRange | public void setSelectionRange(int start, int end)(Code) | | Sets the selection end to the specified position and the selection start
to the specified position. The new end point is constrained to be at or
after the current selection start. If the new start point is different
with the new end point, then will represent the result of highlight in
this text.
Set both arguments to the same value to move the cursor to
the corresponding position without selecting text.
Parameters: start - the start position of the text (included) Parameters: end - the end position of the text (excluded) |
setValueDirectly | protected void setValueDirectly(Object value)(Code) | | Sets the value directly.
Note: Unlike
InputElement.setRawValue (nor setValue), this method
assigns the value directly without clearing error message or
synchronizing with the client.
It is usually used only the constructor.
Though it is also OK to use
InputElement.setRawValue in the constructor,
this method has better performance.
since: 3.0.3 |
|
|