|
HATS 7.5.1 Web API ReferencePublicly accessible methods not documented here are for IBM internal use only and may change in a future release of the product. |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.ibm.hats.transform.widgets.Widget
public abstract class Widget
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 |
|---|
public static final String CLASS_NAME
protected ComponentElement[] componentElements
protected Properties settings
protected ContextAttributes contextAttributes
| Constructor Detail |
|---|
public Widget(ComponentElement[] componentElements,
Properties settings)
componentElements - array of ComponentElementssettings - Widget settings| Method Detail |
|---|
public StringBuffer draw()
draw in interface com.ibm.hats.transform.renderers.TextRendererTextRenderer.draw()public int getPropertyPageCount()
ICustomPropertySupplierNote: Currently only 0 or 1 pages are supported.
getPropertyPageCount in interface ICustomPropertySupplier
public Vector getCustomProperties(int iPageNumber,
Properties properties,
ResourceBundle bundle)
ICustomPropertySuppliercom.ibm.hats.common.HCustomProperty.
getCustomProperties in interface ICustomPropertySupplieriPageNumber - page number containing desired propertiesproperties - existing values for properties defined herebundle - ResourceBundle containing NLS descriptions for the properties
HCustomProperty
public Vector getCustomPropertiesBiDi(int iPageNumber,
Properties properties,
ResourceBundle bundle)
public Class getCustomComposite()
ICustomPropertySupplierClass 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
getCustomComposite in interface ICustomPropertySupplierBasePropertiesComposite) or null if dynamic GUI should be usedBasePropertiesCompositepublic Properties getDefaultValues(int iPageNumber)
ICustomPropertySupplier
getDefaultValues in interface ICustomPropertySupplieriPageNumber - page for which to retrieve default properties
public static Widget newInstance(String className,
ClassLoader classLoader,
ComponentElement[] cea,
Properties settings)
className - class name of the desired WidgetclassLoader - ClassLoader with which to load the Widget, if null, uses the current ClassLoadercea - ComponentElements to pass to Widget constructorsettings - Widget settings to pass to the Widget constructor
public ContextAttributes getContextAttributes()
public void setContextAttributes(ContextAttributes contextAttributes)
contextAttributes - The contextAttributes to set
public void setContextAttribute(String name,
Object value)
name - context attribute namevalue - context attribute valuepublic Object getContextAttribute(String name)
name - context attribute name
public ComponentElement[] getComponentElements()
public Properties getSettings()
public void setComponentElements(ComponentElement[] newElements)
newElements - The new elements to set.public void setSettings(Properties newSettings)
newSettings - The Properties to set.public void insertDir(HTMLElement tableElement)
public void insertAlign(HTMLElement tableElement)
public String convertBidi(String caption,
boolean disableReordering)
|
HATS 7.5.1 (201005110649) | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||