A WebButton is a component that appears as button or link and triggers actions when clicked by the user.

When pressed and released, a WebActionEvent is sent to all listeners added to the WebButton

Clicking a WebButton usually starts a request lifecycle of the WebForm which contains the WebButton: the page is sent to the server, processed, rendered and again displayed by the browser.


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

Properties of the WebButton Component can be easily set in the Property-Editor of the W4T Eclipse Perspective. This example shows how to change the Label or the Color of the Button within the programm flow. The code is located in the in the event handler section and executed when buttons, checkboxes or dropdowns are clicked.

The example WebButton is named wbtExample.

  private void doWbtAppearanceControlWebActionPerformed( WebEvent e ) throws Exception {
    String appearance = wslAppearanceControl.getValue();
    if( appearance.equals( "Image" ) ) {
      wbtExample.setImage( "commit.gif" );
    } else if ( appearance.equals( "Link" ) ) {
      // remove any image name, if one was set
      wbtExample.setImage( "" );
      // make it a link, if it was not yet
      wbtExample.setLink( true );
    } else {
      // remove any image name, if one was set
      wbtExample.setImage( "" );
      wbtExample.setLink( false );
  private void doWbtTitleControlWebActionPerformed( WebEvent e ) throws Exception {
    String title = wtxTitleControl.getValue();
    wbtExample.setTitle( title );
  private void doWbtColorControlWebActionPerformed( WebEvent e ) throws Exception {
    String color = wtxColorControl.getValue().trim();
    WebColor webColor = new WebColor( color );
    wbtExample.getStyle().setColor( webColor );
  private void doWbtExampleWebActionPerformed( WebEvent e ) throws Exception {
    String newCount = String.valueOf( ++counter );
    wlbActionCountDisplayControl.setValue( newCount );
  private void doWbtLabelControlWebActionPerformed( WebEvent e ) throws Exception {
    String text = wtxLabelControl.getValue();
    wbtExample.setLabel( text );
  private void doWbtBgColorControlWebActionPerformed( WebEvent e ) throws Exception {
    String bgColor = wtxBgColorControl.getValue().trim();
    WebColor bgWebColor = new WebColor( bgColor );
    wbtExample.getStyle().setBgColor( bgWebColor );
  private void doWslTextDecorationControlWebItemStateChanged( WebEvent e ) throws Exception {
    WebSelect wsl = ( WebSelect )e.getSource();
    String textDecoration = wsl.getValue();
    wbtExample.getStyle().setTextDecoration( textDecoration );

API documentation

The API documentation for WebButton can be found here.