A WebText is a text component that allows the editing of a single line of text.

When the content of a WebText has changed, a WebItemEvent is sent to all listeners added to the WebText. A WebText encapsulates the HTML <input> element of the type 'text'.


Below you find an example of how to use a WebText. You can try this example online: http://www.innoopract.com/w4content/

Properties of the WebText Component can be easily set in the Property-Editor of the W4T Eclipse Perspective. This example shows how to set various properties of the WebText within the programm flow, for example how to set the alignment, width or the value. The code is located in the in the event handler section and executed when buttons, checkboxes or dropdowns are clicked.

The example WebText is named wtxExample.

  private void doWslTextAlignControlWebItemStateChanged( WebEvent e ) throws Exception {
    WebSelect wsl = ( WebSelect )e.getSource();
    String alignment = wsl.getValue();
    wtxExample.getStyle().setTextAlign( alignment );
  private void doWtxWidthControlWebItemStateChanged( WebEvent e ) throws Exception {
    WebText wtx = ( WebText )e.getSource();
    String width = wtx.getValue();
    wtxExample.getStyle().setWidth( width );
  private void doWbtValueControlWebActionPerformed( WebEvent e ) throws Exception {
    String newValue = wtxValueControl.getValue();
    wtxExample.setValue( newValue );
  private void doWcbPasswordControlWebItemStateChanged( WebEvent e ) throws Exception {
    WebCheckBox wcb = ( WebCheckBox )e.getSource();
    boolean password = wcb.isSelected();
    wtxExample.setPassword( password );
  private void doWtxExampleWebItemStateChanged( WebEvent e ) throws Exception {
    WebText wtx = ( WebText )e.getSource();
    String newValue = wtx.getValue();
    wlbValueDisplayControl.setValue( newValue );
  private void doWslMaxLengthControlWebItemStateChanged( WebEvent e ) throws Exception {
    WebSelect wsl = ( WebSelect )e.getSource();
    int maxLength = Integer.parseInt( wsl.getValue() );
    wtxExample.setMaxLength( maxLength );

API documentation

The API documentation for WebText can be found here.