|
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.html.HTMLElementFactory
public class HTMLElementFactory
HTMLElementFactory is the preferred method for constructing HTMLElements for use by the Widgets. This class consists of a set of creation methods which take component elements as arguments, and properly configure HTMLElements which are tied back to host screen data in name and in javascript function.
HTMLElementFactory maintains a hash of keys to CSS class names for assigning CSS classes to HTMLElements automatically. The LINK_CLASS, INPUT_CLASS, etc static String fields are used as the keys into this hash. The CSS mapping can be automatically generated from the widgetSettings using HTMLWidgetUtilities. Alternately, the hash can be populated manually.
Finally, the HTMLElementFactory maintains a String of style overrides which will be applied to all HTMLElements produced.
Example of rendering a list of component elements:
HTMLElementFactory factory = HTMLElementFactory.newInstance(contextAttributes,widgetSettings);
factory.setCSSMapping(HTMLWidgetUtilities.processCSSOverrides(widgetSettings));
factory.setStyleOverrides("backgroundColor:green;");
//alternately
//factory.getCSSMapping.put(INPUT_CLASS,"MyCSSInputClass");
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>");
}
HTMLElement,
HTMLRenderer,
HTMLWidgetUtilities| Field Summary | |
|---|---|
static String |
BUTTON_CLASS
CSS class mapping key to be used for HTML input buttons |
static String |
CHECKBOX_CLASS
CSS class mapping key to be used for HTML checkboxes |
static String |
CLASSNAME
|
protected ContextAttributes |
contextAttributes
The factory's associated context attributes. |
static String |
DESCRIPTION_CLASS
CSS class mapping key to be used for HTML radio button descriptions |
static String |
IMGLINK_CLASS
CSS class mapping key to be used for a popup launcher element |
static String |
INPUT_CLASS
CSS class mapping key to be used for HTML text input elements |
static String |
ITEMLINK_CLASS
CSS class mapping key to be used for popup item elements |
static String |
LABEL_CLASS
CSS class mapping key to be used for assigning a class to a caption |
static String |
LINK_CLASS
CSS class mapping key to be used for HTML A element |
static String |
OPTION_CLASS
CSS class mapping key to be used for HTML option elements |
static String |
POPUP_CLASS
CSS class mapping key to be used for a popup DIV element |
static String |
POPUP_TABLE_CLASS
CSS class mapping key to be used for HTML table in a popup |
static String |
POPUP_TD_CLASS
CSS class mapping key to be used for HTML table in a popup |
static String |
POPUP_TH_CLASS
CSS class mapping key to be used for HTML table in a popup |
static String |
POPUP_TR_CLASS
CSS class mapping key to be used for HTML table in a popup |
static String |
RADIOBUTTON_CLASS
CSS class mapping key to be used for HTML input radio element |
static String |
SELECT_CLASS
CSS class mapping key to be used for HTML select elements |
static String |
TABLE_CLASS
CSS class mapping key to be used for HTML table element |
static String |
TABLECAPTIONCELL_CLASS
CSS class mapping key to be used for HTML table caption cell |
static String |
TABLECELL_CLASS
CSS class mapping key to be used for HTML table cell element |
static String |
TABLEEVENROW_CLASS
CSS class mapping key to be used for HTML table even numbered row |
static String |
TABLEHEADERROW_CLASS
CSS class mapping key to be used for HTML table header row |
static String |
TABLEODDROW_CLASS
CSS class mapping key to be used for HTML table odd numbered row |
static String |
TABLEROW_CLASS
CSS class mapping key to be used for HTML table row element |
protected Properties |
widgetSettings
The factory's associated widget settings. |
| Constructor Summary | |
|---|---|
HTMLElementFactory(ContextAttributes contextAttributes,
Properties widgetSettings)
Class constructor which assigns the context attributes and widget settings. |
|
HTMLElementFactory(Hashtable contextAttributes,
Properties widgetSettings)
Deprecated. |
|
| Method Summary | |
|---|---|
TextInputElement |
addCheckAttributesSupport(TextInputElement tie,
FieldComponentElement fce)
Adds field check keyword support to HTML input fields. |
TextInputElement |
addInputRestrictionsSupport(TextInputElement tie,
FieldComponentElement fce)
Adds input restrictions to a TextInputElement based on the associated FieldComponentElement's extended attributes. |
AccessibilityLabelElement |
createAccessibilityLabel(HTMLElement target,
String description)
Creates an accessibility label for the specified HTMLElement. |
ButtonElement |
createButton(FunctionKeyComponentElement fkce)
Creates a ButtonElement from a FunctionKeyComponentElement. |
ButtonElement |
createButton(ListItemComponentElement lice)
Creates a ButtonElement from a ListItemComponentElement. |
CheckboxElement |
createCheckbox(InputComponentElement ice)
Creates a CheckBoxElement from an InputComponentElement. |
SelectElement |
createDropdown(ComponentElementList cel,
String captionType)
Creates a SelectElement from a ComponentElementList. |
SelectElement |
createDropdown(SelectionComponentElement sce,
String captionType)
Calls createDropdown(SelectionComponentElement,String,int) with a 0 mininum item length. |
SelectElement |
createDropdown(SelectionComponentElement sce,
String captionType,
int minItemLength)
Creates a SelectElement from a SelectionComponentElement. |
HTMLElement |
createElementFromComponent(ComponentElement ce)
Returns null. |
HTMLElement |
createGenericElement(String tagName)
Convenience method for creating an untyped HTMLElement with the specified tag name, also applies the style overrides. |
HTMLElement |
createGenericElement(String tagName,
String classKey)
Convenience method for creating an untyped HTMLElement with the specified tag name, also applies the style overrides and performs a CSS class lookup. |
InputElement |
createHiddenInput(FieldComponentElement ce)
Creates a InputElement of type hidden from a FieldComponentElement. |
LinkElement |
createLink(FunctionKeyComponentElement fkce)
Creates a LinkElement from a FunctionKeyComponentElement. |
LinkElement |
createLink(ListItemComponentElement lice)
Creates a LinkElement from a ListItemComponentElement. |
LinkElement |
createLink(URLComponentElement urlce)
Creates a LinkElement from a URLComponentElement. |
OptionElement |
createOptionElement(FunctionKeyComponentElement fkce,
String captionType)
Creates an OptionElement from a FunctionKeyComponentElement. |
OptionElement |
createOptionElement(ListItemComponentElement item,
String captionType)
Creates an OptionElement from a ListItemComponentElement. |
PopupElement |
createPopup(SelectionComponentElement sce)
|
PopupElement |
createPopup(SelectionComponentElement sce,
String captionType,
boolean autoSubmit)
Creates a PopupElement from a SelectionComponentElement. |
RadioInputElement |
createRadioButton(FunctionKeyComponentElement fkce,
String captionType)
Creates a RadioInputElement from a FunctionKeyComponentElement. |
RadioInputElement |
createRadioButton(ListItemComponentElement item,
String captionType)
Creates a RadioInputElement from a ListItemComponentElement. |
ArrayList |
createRadioButtons(ComponentElementList cel,
String captionType)
Creates an ArrayList of RadioInputElements from a ComponentElementList. |
ArrayList |
createRadioButtons(SelectionComponentElement sce,
String captionType)
Creates an ArrayList of RadioInputElements from a SelectionComponentElement |
InputElement |
createSubmitButton(FieldComponentElement fce)
Creates a InputElement of type button from a FieldComponentElement. |
ArrayList |
createTargetField(SelectionComponentElement sce)
|
TextInputElement |
createTextInput(FieldComponentElement ce)
Creates a TextInputElement from a FieldComponentElement. |
boolean |
escapeHTML()
|
static String |
generateElementName(FieldComponentElement fce)
Generates a HATS-formatted form element name for the specified field, calls generateElementName with the field's start position and length. |
static String |
generateElementName(FieldComponentElement fce,
int screenid)
|
static String |
generateElementName(int startPos,
int length)
Generates an encoded name for an html element corresponding the region of the screen with the specified parameters. |
static String |
generateElementName(int startPos,
int length,
int screenId)
|
String |
generatePositionId(int pos)
|
String |
generatePositionId(int pos,
String prefix)
|
static String |
getCaption(FunctionKeyComponentElement fkce,
String captionType)
Creates a caption from a FunctionKeyComponentElement. |
static String |
getCaption(ListItemComponentElement lice,
String captionType)
Creates a caption from a ListItemComponentElement. |
ContextAttributes |
getContextAttributes()
Gets the context attributes associated with this factory. |
Map |
getCSSMapping()
Returns the CSS class mapping. |
String |
getStyleOverrides()
Returns the style overrides which are applied to all generated HTML elements. |
String |
getValidValuesPopupId(String fieldName)
Generates the html element id for popup's floating region. |
static HTMLElementFactory |
newInstance(ContextAttributes contextAttributes,
Properties widgetSettings)
Preferred method for creating instances of an HTMLElementFactory. |
static HTMLElementFactory |
newInstance(Hashtable contextAttributes,
Properties widgetSettings)
Deprecated. |
void |
setClass(HTMLElement e,
String key)
Sets the classname for an HTML element from the stored CSS class mapping. |
void |
setContextAttributes(ContextAttributes attribs)
Sets the context attributes for this factory. |
void |
setContextAttributes(Hashtable attribs)
Deprecated. |
void |
setCSSMapping(Map m)
Sets the CSS class mapping. |
void |
setStyle(HTMLElement e)
Sets the style overrides for an HTMLElement from the stored style overrides. |
void |
setStyleOverrides(String styleOverrides)
Sets the styleOverrides. |
void |
setWidgetSettings(Properties widgetSettings)
Assigns the associated widget settings for this factory. |
TextInputElement |
stripUnderscoresFromValue(TextInputElement tie)
Removes underscores from the end of a text input's value, and repads the value with spaces. |
TextInputElement |
trimSpacesFromValue(TextInputElement tie)
Trims the value of a TextInputElement using the String.trim() method. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final String CLASSNAME
public static final String SELECT_CLASS
public static final String OPTION_CLASS
public static final String INPUT_CLASS
public static final String POPUP_CLASS
public static final String POPUP_TABLE_CLASS
public static final String POPUP_TR_CLASS
public static final String POPUP_TH_CLASS
public static final String POPUP_TD_CLASS
public static final String LINK_CLASS
public static final String IMGLINK_CLASS
public static final String ITEMLINK_CLASS
public static final String RADIOBUTTON_CLASS
public static final String TABLE_CLASS
public static final String TABLEROW_CLASS
public static final String TABLECELL_CLASS
public static final String TABLEODDROW_CLASS
public static final String TABLEEVENROW_CLASS
public static final String TABLEHEADERROW_CLASS
public static final String TABLECAPTIONCELL_CLASS
public static final String LABEL_CLASS
public static final String DESCRIPTION_CLASS
public static final String BUTTON_CLASS
public static final String CHECKBOX_CLASS
protected ContextAttributes contextAttributes
protected Properties widgetSettings
| Constructor Detail |
|---|
public HTMLElementFactory(ContextAttributes contextAttributes,
Properties widgetSettings)
HTMLElementFactory.newInstance(Hashtable, Properties)
public HTMLElementFactory(Hashtable contextAttributes,
Properties widgetSettings)
HTMLElementFactory.newInstance(Hashtable, Properties)| Method Detail |
|---|
public HTMLElement createElementFromComponent(ComponentElement ce)
public TextInputElement createTextInput(FieldComponentElement ce)
public InputElement createHiddenInput(FieldComponentElement ce)
hidden from a FieldComponentElement.
public ArrayList createTargetField(SelectionComponentElement sce)
public SelectElement createDropdown(SelectionComponentElement sce,
String captionType)
HTMLElementFactory.createDropdown(SelectionComponentElement, String, int)
public SelectElement createDropdown(SelectionComponentElement sce,
String captionType,
int minItemLength)
sce - the SelectionComponentElementcaptionType - used as parameter when constructing OptionElements captionsminItemLength - minimum length for option values, will be used to pad OptionElement valuesHTMLElementFactory.getCaption(ListItemComponentElement, String)
public SelectElement createDropdown(ComponentElementList cel,
String captionType)
cel - the ComponentElementListcaptionType - used as parameter when constructing OptionElements captionsHTMLElementFactory.createDropdown(SelectionComponentElement, String, int),
HTMLElementFactory.getCaption(ListItemComponentElement, String)
public ArrayList createRadioButtons(SelectionComponentElement sce,
String captionType)
sce - the ComponentElementcaptionType - used as parameter when constructing RadioInputElement descriptions
HTMLElementFactory.createRadioButton(ListItemComponentElement, String),
HTMLElementFactory.getCaption(ListItemComponentElement, String)
public ArrayList createRadioButtons(ComponentElementList cel,
String captionType)
cel - the ComponentElementListcaptionType - used as parameter when constructing OptionElements captionsHTMLElementFactory.createRadioButtons(SelectionComponentElement, String),
HTMLElementFactory.getCaption(ListItemComponentElement, String)public PopupElement createPopup(SelectionComponentElement sce)
public PopupElement createPopup(SelectionComponentElement sce,
String captionType,
boolean autoSubmit)
public ButtonElement createButton(FunctionKeyComponentElement fkce)
fkce - the function Key
public RadioInputElement createRadioButton(FunctionKeyComponentElement fkce,
String captionType)
fkce - the function keycaptionType - used as parameter when constructing the description for this radio button
HTMLElementFactory.getCaption(FunctionKeyComponentElement, String)
public RadioInputElement createRadioButton(ListItemComponentElement item,
String captionType)
item - the list itemcaptionType - used as parameter when constructing the description for this radio button
HTMLElementFactory.getCaption(ListItemComponentElement, String)
public OptionElement createOptionElement(ListItemComponentElement item,
String captionType)
item - the list itemcaptionType - used as parameter when constructing the description for this option
HTMLElementFactory.getCaption(ListItemComponentElement, String)
public OptionElement createOptionElement(FunctionKeyComponentElement fkce,
String captionType)
fkce - the function keycaptionType - used as parameter when constructing the description for this option
HTMLElementFactory.getCaption(FunctionKeyComponentElement, String)public InputElement createSubmitButton(FieldComponentElement fce)
button from a FieldComponentElement. The HTML button will put focus into the specified field and
send its associated action key.
fce - the field
public LinkElement createLink(FunctionKeyComponentElement fkce)
fkce - The function key.
public ButtonElement createButton(ListItemComponentElement lice)
lice - the list item
public LinkElement createLink(ListItemComponentElement lice)
lice - the list item
public LinkElement createLink(URLComponentElement urlce)
LinkElement from a URLComponentElement. The HTML link will redirect the browser to the associated URL.
urlce - the url
public CheckboxElement createCheckbox(InputComponentElement ice)
ice - the input field
public AccessibilityLabelElement createAccessibilityLabel(HTMLElement target,
String description)
target - the targeted HTML elementdescription - the description of the targeted element
public HTMLElement createGenericElement(String tagName)
Example:
HTMLElement tableCell = factory.createGenericElement("TD");
tagName - the desired tag name
public HTMLElement createGenericElement(String tagName,
String classKey)
Example:
HTMLElement tableCell = factory.createGenericElement("TD",HTMLElementFactory.TABLECELL_CLASS);
tagName - the desired tag nameclassKey - the CSS class mapping key for this element
public static String generateElementName(FieldComponentElement fce)
fce - the field
HTMLElementFactory.generateElementName(int, int)
public static String generateElementName(FieldComponentElement fce,
int screenid)
public static String generateElementName(int startPos,
int length)
startPos - The region's start position.length - The region's length.
public static String generateElementName(int startPos,
int length,
int screenId)
public String generatePositionId(int pos)
public String generatePositionId(int pos,
String prefix)
public Map getCSSMapping()
public String getStyleOverrides()
public void setStyle(HTMLElement e)
e - the HTML element to configure
public void setClass(HTMLElement e,
String key)
e - the HTML element to configurekey - the CSS class mapping keypublic void setCSSMapping(Map m)
m - The cssClasses to setpublic void setStyleOverrides(String styleOverrides)
styleOverrides - The styleOverrides to setpublic ContextAttributes getContextAttributes()
public void setContextAttributes(ContextAttributes attribs)
attribs - The context attributes to be set.public void setContextAttributes(Hashtable attribs)
attribs - The context attributes to be set.public String getValidValuesPopupId(String fieldName)
fieldName - the HSR-formatted form element name for the input field of the popup
public TextInputElement addInputRestrictionsSupport(TextInputElement tie,
FieldComponentElement fce)
tie - the HTML input to configurefce - the field associated with the input
public TextInputElement addCheckAttributesSupport(TextInputElement tie,
FieldComponentElement fce)
Validity checking (5250 only):
Keyboard control (5250 only):
tie - the html text input to configurefce - the field associated with this text input
public TextInputElement stripUnderscoresFromValue(TextInputElement tie)
tie - the text input to update
public TextInputElement trimSpacesFromValue(TextInputElement tie)
tie - text input to trim
public static HTMLElementFactory newInstance(ContextAttributes contextAttributes,
Properties widgetSettings)
contextAttributes - widgetSettings -
public static HTMLElementFactory newInstance(Hashtable contextAttributes,
Properties widgetSettings)
contextAttributes - widgetSettings -
public void setWidgetSettings(Properties widgetSettings)
widgetSettings -
public static String getCaption(ListItemComponentElement lice,
String captionType)
TOKEN, this returns ListItemComponentElement.getItem().
If the caption type is BOTH, returns ListItemComponentElement.getFullCaption(). If captionType is null or any other value,
this returns ListItemComponentElement.getDescription().
lice - list item to construct caption fromcaptionType - type of caption to build
public static String getCaption(FunctionKeyComponentElement fkce,
String captionType)
TOKEN, this returns FunctionKeyComponentElement.getItem().
If the caption type is BOTH, returns FunctionKeyComponentElement.getFullCaption(). If captionType is null or any other value,
this returns FunctionKeyComponentElement.getCaption().
fkce - function key to construct caption fromcaptionType - type of caption to build
public boolean escapeHTML()
|
HATS 7.5.1 (201005110649) | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||