Package org.zkoss.zul

Class Textbox

All Implemented Interfaces:
Serializable, Cloneable, Component, Disable, Readonly, Scope, ComponentCtrl, Constrainted
Direct Known Subclasses:
Bandbox, Combobox

public class Textbox extends InputElement
A textbox.

See Specification.

Default getZclass(): z-textbox.(since 3.5.0)

When multiline is true, only default mold is available.

Author:
tomyeh
See Also:
  • Constructor Details

  • Method Details

    • getValue

      public String getValue() throws WrongValueException
      Returns the value. The same as InputElement.getText().

      Default: "".

      Throws:
      WrongValueException - if user entered a wrong value
    • setValue

      public void setValue(String value) throws WrongValueException
      Sets the value.
      Parameters:
      value - the value; If null, it is considered as empty.
      Throws:
      WrongValueException - if value is wrong
    • coerceFromString

      protected Object coerceFromString(String value) throws WrongValueException
      Coerces the value passed to setValue(java.lang.String).

      Default: convert null to an empty string.

      Specified by:
      coerceFromString in class InputElement
      Throws:
      WrongValueException
    • coerceToString

      protected String coerceToString(Object value)
      Coerces the value passed to setValue(java.lang.String).

      Default: convert null to an empty string.

      Specified by:
      coerceToString in class InputElement
    • getType

      public String getType()
      Returns the type.

      Default: text.

      Overrides:
      getType in class InputElement
    • setType

      public void setType(String type) throws WrongValueException
      Sets the type.
      Parameters:
      type - the type. Acceptable values are "text" and "password". Unlike XUL, "timed" is redundant because it is enabled as long as onChanging is added. Since 6.5.0 type also support tel, email and url.
      Throws:
      WrongValueException
    • getRows

      public int getRows()
      Returns the rows.

      Default: 1.

    • setRows

      public void setRows(int rows) throws WrongValueException
      Sets the rows.

      Note: Not allowed to set rows and height/vflex at the same time

      Throws:
      WrongValueException
    • checkBeforeSetRows

      protected void checkBeforeSetRows() throws UiException
      Internal check if there is any use of vflex and height before setRows
      Throws:
      UiException
    • isMultiline

      public boolean isMultiline()
      Returns whether it is multiline.

      Default: false.

      Overrides:
      isMultiline in class InputElement
    • setMultiline

      public void setMultiline(boolean multiline)
      Sets whether it is multiline.
    • isTabbable

      public boolean isTabbable()
      Returns whether TAB is allowed. If true, the user can enter TAB in the textbox, rather than change focus.

      Default: false.

      Since:
      3.6.0
    • setTabbable

      public void setTabbable(boolean tabbable)
      Sets whether TAB is allowed. If true, the user can enter TAB in the textbox, rather than change focus.

      Default: false.

      Since:
      3.6.0
    • isSubmitByEnter

      public boolean isSubmitByEnter()
      Returns whether it is submitByEnter, If submitByEnter is true, press enter will fire onOK event instead of move to next line, you should press shift + enter if you want to move to next line.

      Default: false.

      Returns:
      true if it is submitByEnter.
      Since:
      8.5.2
    • setSubmitByEnter

      public void setSubmitByEnter(boolean submitByEnter)
      Sets whether it is submitByEnter. If submitByEnter is true, press enter will fire onOK event instead of move to next line, you should press shift + enter if you want to move to next line.
      Parameters:
      submitByEnter - whether it is submitByEnter
      Since:
      8.5.2
    • setVflex

      public void setVflex(String flex)
      Description copied from class: HtmlBasedComponent
      Sets vertical flexibility hint of this component.

      Number flex indicates how this component's container distributes remaining empty space among its children vertically. Flexible component grow and shrink to fit their given space. Flexible components with larger flex values will be made larger than components with lower flex values, at the ratio determined by all flexible components. The actual flex value is not relevant unless there are other flexible components within the same container. Once the default sizes of components in a container are calculated, the remaining space in the container is divided among the flexible components, according to their flex ratios.

      Specify a flex value of negative value, 0, or "false" has the same effect as leaving the flex attribute out entirely. Specify a flex value of "true" has the same effect as a flex value of 1.

      Special flex hint, "min", indicates that the minimum space shall be given to this flexible component to enclose all of its children components. That is, the flexible component grow and shrink to fit its children components.

      Overrides:
      setVflex in class HtmlBasedComponent
      Parameters:
      flex - the vertical flex hint.
      See Also:
    • setHeight

      public void setHeight(String height)
      Description copied from class: HtmlBasedComponent
      Sets the height. If null, the best fit is used.
      Overrides:
      setHeight in class HtmlBasedComponent
    • clone

      public Object clone()
      Description copied from interface: Component
      Clones the component. All of its children and descendants are cloned. Also, ID are preserved.
      Specified by:
      clone in interface Component
      Overrides:
      clone in class InputElement
      Returns:
      the new component. Notice that it doesn't belong to any page, nor desktop. It doesn't have a parent, either.
    • getPropertyAccess

      public PropertyAccess getPropertyAccess(String prop)
      Description copied from interface: ComponentCtrl
      Returns the corresponding property access object from the given property name, if any.
      Specified by:
      getPropertyAccess in interface ComponentCtrl
      Overrides:
      getPropertyAccess in class InputElement
      Parameters:
      prop - the name of the property
      Returns:
      null it means not to support for the property name.
    • renderProperties

      protected void renderProperties(ContentRenderer renderer) throws IOException
      Description copied from class: HtmlBasedComponent
      Renders the content of this component, excluding the enclosing tags and children.

      See also ZK Client-side Reference: Property Rendering

      Overrides:
      renderProperties in class InputElement
      Throws:
      IOException
    • getZclass

      public String getZclass()
      Description copied from class: HtmlBasedComponent
      Returns 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 of HtmlBasedComponent.getZclass(). Once it is changed, the default style won't be applied at all. If you want to perform small adjustments, use HtmlBasedComponent.setSclass(java.lang.String) instead.

      Overrides:
      getZclass in class HtmlBasedComponent
      See Also: