HATS 7.5.1 Web API Reference

Publicly accessible methods not documented here are for IBM internal use only and may change in a future release of the product.

com.ibm.hats.transform.widgets
Class Widget

java.lang.Object
  extended by com.ibm.hats.transform.widgets.Widget
All Implemented Interfaces:
ICustomPropertySupplier, com.ibm.hats.transform.renderers.TextRenderer
Direct Known Subclasses:
AbstractButtonTableWidget, AbstractButtonWidget, AbstractCheckboxWidget, AbstractFieldWidget, AbstractInputWidget, AbstractLinkWidget, AbstractRadioButtonWidget, AbstractTableWidget, BasicDialogWidget, BasicSLRadioButtonWidget, CalendarWidget, DropdownWidget, EnptuiScrollbarWidget, GraphWidget, ISRadioButtonWidget, ItemSelectionLinkWidget, LabelWidget, PopupWidget, SLDropdownWidget, SubfileWidget

public abstract class Widget
extends Object
implements com.ibm.hats.transform.renderers.TextRenderer, ICustomPropertySupplier

Widget is the parent class for all built-in widgets and any custom Widgets. Widgets are responsible for taking context attributes, settings, and an array of ComponentElements, and generating content. Widget implements TextRenderer so all extensions of Widget will be able to produce text content, but to produce HTML content, you must implement HTMLRenderer in your extension of this class.

Example custom Widget which renders InputComponentElements as input fields with green backgrounds:

 public class CustomWidget extends Widget implements HTMLRenderer {
 
     public CustomWidget(ComponentElement[] componentElements, Properties settings) {
         super(componentElements, settings);
     }
 
     public StringBuffer drawHTML() {
         StringBuffer buffer = new StringBuffer(256);
         HTMLElementFactory factory = HTMLElementFactory.newInstance(contextAttributes, settings);
         factory.setCSSMapping(HTMLWidgetUtilities.processCSSOverrides(settings));
         factory.setStyleOverrides("backgroundColor:green;");
         for (int i = 0; i < componentElements.length; i++) {
             InputComponentElement ice = (InputComponentElement) componentElements[i];
             //create and render the html input field's caption
             HTMLWidgetUtilities.renderCaption(ice.getCaption(), factory, buffer);
             //create the html input field from the input component element, then render it
             TextInputElement input = factory.createTextInput(ice);
             input.render(buffer);
             //insert a line break
             buffer.append("<br>");
         }
 
         return buffer;
     }
 }
 


Field Summary
static String CLASS_NAME
           
protected  ComponentElement[] componentElements
          Array of ComponentElements to be rendered by this Widget.
protected  ContextAttributes contextAttributes
          A collectioin of attributes defining properties pertaining to the environment in which this Widget is executing, such as Websphere Studio or Servlet runtime.
protected  Properties settings
          Settings to be used by this widget during rendering, representing specific properties of the widget, such as layout or style information.
 
Fields inherited from interface com.ibm.hats.common.ICustomPropertySupplier
CLASSNAME
 
Constructor Summary
Widget(ComponentElement[] componentElements, Properties settings)
          Class constructor for Widget.
 
Method Summary
 String convertBidi(String caption, boolean disableReordering)
           
 StringBuffer draw()
          Creates a StringBuffer by calling toString on all the ComponentElements for this Widget.
 ComponentElement[] getComponentElements()
          Gets the Widget's array of ComponentElements.
 Object getContextAttribute(String name)
          Convenience method for getting an attribute from the context attibutes
 ContextAttributes getContextAttributes()
          Returns the contextAttributes associated with this Widget
 Class getCustomComposite()
          Returns a Class object (assignable from com.ibm.hats.studio.composites.BasePropertiesComposite) if a custom composite is to be used to represent the customizable properties for this object or null if dynamic GUI is to be used.
 Vector getCustomProperties(int iPageNumber, Properties properties, ResourceBundle bundle)
          Returns a list of this object's custom properties.
 Vector getCustomPropertiesBiDi(int iPageNumber, Properties properties, ResourceBundle bundle)
           
 Properties getDefaultValues(int iPageNumber)
          Returns this object's default property values.
 int getPropertyPageCount()
          Returns the number of property pages associated with this object.
 Properties getSettings()
          Gets the Widget's settings.
 void insertAlign(HTMLElement tableElement)
           
 void insertDir(HTMLElement tableElement)
           
static Widget newInstance(String className, ClassLoader classLoader, ComponentElement[] cea, Properties settings)
          Convenience method for using reflection to load a Widget from its class name.
 void setComponentElements(ComponentElement[] newElements)
          Sets the Widget's array of ComponentElements.
 void setContextAttribute(String name, Object value)
          Convenience method for setting an attribute on a Widget which will be stored in its context attributes.
 void setContextAttributes(ContextAttributes contextAttributes)
          Sets the contextAttributes of this Widget
 void setSettings(Properties newSettings)
          Sets the Widget's settings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_NAME

public static final String CLASS_NAME
See Also:
Constant Field Values

componentElements

protected ComponentElement[] componentElements
Array of ComponentElements to be rendered by this Widget.


settings

protected Properties settings
Settings to be used by this widget during rendering, representing specific properties of the widget, such as layout or style information.


contextAttributes

protected ContextAttributes contextAttributes
A collectioin of attributes defining properties pertaining to the environment in which this Widget is executing, such as Websphere Studio or Servlet runtime.

Constructor Detail

Widget

public Widget(ComponentElement[] componentElements,
              Properties settings)
Class constructor for Widget. Assigns the internal references to the ComponentElements and Widget settings. Calls setComponentElements method and setSettings method for assignment.

Parameters:
componentElements - array of ComponentElements
settings - Widget settings
Method Detail

draw

public StringBuffer draw()
Creates a StringBuffer by calling toString on all the ComponentElements for this Widget.

Specified by:
draw in interface com.ibm.hats.transform.renderers.TextRenderer
See Also:
TextRenderer.draw()

getPropertyPageCount

public int getPropertyPageCount()
Description copied from interface: ICustomPropertySupplier
Returns the number of property pages associated with this object.

Note: Currently only 0 or 1 pages are supported.

Specified by:
getPropertyPageCount in interface ICustomPropertySupplier
Returns:
the number of defined property pages used to configure this object, or 0 if there are none

getCustomProperties

public Vector getCustomProperties(int iPageNumber,
                                  Properties properties,
                                  ResourceBundle bundle)
Description copied from interface: ICustomPropertySupplier
Returns a list of this object's custom properties. Items must be of type com.ibm.hats.common.HCustomProperty.

Specified by:
getCustomProperties in interface ICustomPropertySupplier
Parameters:
iPageNumber - page number containing desired properties
properties - existing values for properties defined here
bundle - ResourceBundle containing NLS descriptions for the properties
Returns:
Vector containing all the custom properties for this object, or null if there are none
See Also:
HCustomProperty

getCustomPropertiesBiDi

public Vector getCustomPropertiesBiDi(int iPageNumber,
                                      Properties properties,
                                      ResourceBundle bundle)

getCustomComposite

public Class getCustomComposite()
Description copied from interface: ICustomPropertySupplier
Returns a Class object (assignable from com.ibm.hats.studio.composites.BasePropertiesComposite) if a custom composite is to be used to represent the customizable properties for this object or null if dynamic GUI is to be used. Note: this function only applies to HATS Studio

Specified by:
getCustomComposite in interface ICustomPropertySupplier
Returns:
custom composite (of type BasePropertiesComposite) or null if dynamic GUI should be used
See Also:
BasePropertiesComposite

getDefaultValues

public Properties getDefaultValues(int iPageNumber)
Description copied from interface: ICustomPropertySupplier
Returns this object's default property values.

Specified by:
getDefaultValues in interface ICustomPropertySupplier
Parameters:
iPageNumber - page for which to retrieve default properties
Returns:
object's default properties

newInstance

public static Widget newInstance(String className,
                                 ClassLoader classLoader,
                                 ComponentElement[] cea,
                                 Properties settings)
Convenience method for using reflection to load a Widget from its class name.

Parameters:
className - class name of the desired Widget
classLoader - ClassLoader with which to load the Widget, if null, uses the current ClassLoader
cea - ComponentElements to pass to Widget constructor
settings - Widget settings to pass to the Widget constructor
Returns:
newly instantiated Widget

getContextAttributes

public ContextAttributes getContextAttributes()
Returns the contextAttributes associated with this Widget

Returns:
ContextAttributes

setContextAttributes

public void setContextAttributes(ContextAttributes contextAttributes)
Sets the contextAttributes of this Widget

Parameters:
contextAttributes - The contextAttributes to set

setContextAttribute

public void setContextAttribute(String name,
                                Object value)
Convenience method for setting an attribute on a Widget which will be stored in its context attributes.

Parameters:
name - context attribute name
value - context attribute value

getContextAttribute

public Object getContextAttribute(String name)
Convenience method for getting an attribute from the context attibutes

Parameters:
name - context attribute name
Returns:
context attribute value

getComponentElements

public ComponentElement[] getComponentElements()
Gets the Widget's array of ComponentElements.

Returns:
ComponentElement[]

getSettings

public Properties getSettings()
Gets the Widget's settings.

Returns:
Properties

setComponentElements

public void setComponentElements(ComponentElement[] newElements)
Sets the Widget's array of ComponentElements.

Parameters:
newElements - The new elements to set.

setSettings

public void setSettings(Properties newSettings)
Sets the Widget's settings.

Parameters:
newSettings - The Properties to set.

insertDir

public void insertDir(HTMLElement tableElement)

insertAlign

public void insertAlign(HTMLElement tableElement)

convertBidi

public String convertBidi(String caption,
                          boolean disableReordering)

HATS 7.5.1 (201005110649)