WebAnchor

General

A WebAnchor is a component which branches to a location that is reachable for the displaying browser, as URL of files, websites, or other WebAnchors on the same formular.

WebAnchor encapsulates the HTML <a> tag.

Example

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

Properties of the WebAnchor Component can be easily set in the Property-Editor of the W4T Eclipse Perspective. This example shows how to set the appereance of a WebAnchor or its target (_blank for new window) programmatically. The code is located in the in the event handler section and executed when buttons or checkboxes are clicked.

The example WebAnchor is named wanExample.

  private void doWslTextDecorationControlWebItemStateChanged( WebEvent e ) throws Exception {
    WebSelect wsl = ( WebSelect )e.getSource();
    String textDecoration = wsl.getValue();
    wanExample.getStyle().setTextDecoration( textDecoration );
  }
  
  private void doWbtContentControlWebActionPerformed( WebEvent e ) throws Exception {
    String appearance = wslContentControl.getValue();
    if( appearance.equals( "Image" ) ) {
      wanExample.setContent( imageContent );
    } else if ( appearance.equals( "Button" ) ) {
      wanExample.setContent( buttonContent );
    } else {
      wanExample.setContent( labelContent );
    }
  }

  private void changeContentToLabel() throws Exception {
    wanExample.setContent( labelContent );
  }
  
  private void doWbtTitleControlWebActionPerformed( WebEvent e ) throws Exception {
    String title = wtxTitleControl.getValue();
    wanExample.setTitle( title );
  }
  
  private void doWcbEnabledControlWebItemStateChanged( WebEvent e ) throws Exception {
    WebCheckBox wcb = ( WebCheckBox )e.getSource();
    boolean enabled = wcb.isSelected();
    wanExample.setEnabled( enabled );
  }
  
  private void doWbtHREFControlWebActionPerformed( WebEvent e ) throws Exception {
    
  }
  
  private void doWbtColorControlWebActionPerformed( WebEvent e ) throws Exception {
    String color = wtxColorControl.getValue().trim();
    WebColor webColor = new WebColor( color );
    wanExample.getStyle().setColor( webColor );
  }
  
  private void doWanExampleWebActionPerformed( WebEvent e ) throws Exception {
    
  }
  
  private void doWslTargetControlWebItemStateChanged( WebEvent e ) throws Exception {
    WebSelect wsl = ( WebSelect )e.getSource();
    String target = wsl.getValue();
    wanExample.setTarget( target );
  }
  

API documentation

The API documentation for WebAnchor can be found here.