public interface HTMLCallback

ExtendsParserCallback

Known subtypesAds, DefaultHTMLCallback

HTMLCallback is used to dispatch document lifecycle events. Most methods are called on the EDT thread, except parsingError, getAutoComplete and getLinkProperties

Fields

public static final int ERROR_CONNECTING = 100Error code denoting that a connection to the resource provider/server could not be made
public static final int ERROR_IMAGE_NOT_FOUND = 101Error code denoting that an image referenced from the HTML was not found
public static final int ERROR_IMAGE_BAD_FORMAT = 102Error code denoting that an image referenced from the HTML could not be loaded
public static final int ERROR_NO_BASE_URL = 103Error code denoting that a relative URL was referenced from a document with no base URL (A document that was loaded via setBody/setHTML/setDOM and not via setPage) In this case the return value of parsingError is not considered - parsing co…
public static final int ERROR_INVALID_TAG_HIERARCHY = 104Error code denoting that a tag contains tags it shouldn’t, or that a tag doesn’t have the parent tag it should have
public static final int STATUS_NONE = -3This is returned in the page status if no page has been set to the HTMLComponent
public static final int STATUS_ERROR = -2The page couldn’t load completely because of parsing errors
public static final int STATUS_CANCELLED = -1The page loading was cancelled before it could be completed
public static final int STATUS_REQUESTED = 0The page was requested from the request handler
public static final int STATUS_CONNECTED = 1The stream was received
public static final int STATUS_PARSED = 2The page was parsed
public static final int STATUS_DISPLAYED = 3The page was displayed on screen - but at this stage some images and CSS files may still be loading in the background
public static final int STATUS_COMPLETED = 4The page and all of its referenced images and CSS files were loaded completely
public static final int STATUS_REDIRECTED = 5The page was redirected to another URL
public static final int FIELD_TEXT = 0A text field
public static final int FIELD_PASSWORD = 1A password field
public static final int LINK_REGULAR = 0A regular link
public static final int LINK_VISTED = 1A link that was visited before
public static final int LINK_FORBIDDEN = 2A forbidden link (not to be rendered as a link but as a regular label)
public static final int ERROR_CSS_ATTRIBUTE_NOT_SUPPORTED = 200Error code denoting that an unsupported CSS attribute (by XHTML-MP 1.0 standards) was found in the HTML or external CSS files
public static final int ERROR_CSS_ATTIBUTE_VALUE_INVALID = 201Error code denoting that an invalid attribute value was found in the CSS
public static final int ERROR_CSS_NOT_FOUND = 202Error code denoting that a CSS file referenced from the HTML or from another external CSS file was not found
public static final int ERROR_CSS_NO_BASE_URL = 203Error code denoting that a relative URL was referenced from a document with no base URL (A document that was loaded via setBody/setHTML/setDOM and not via setPage) In this case the return value of parsingError is not considered - parsing co…

Methods

public abstract void titleUpdated(HTMLComponent htmlC, String title)Called when the page’s title is updated
public abstract void pageStatusChanged(HTMLComponent htmlC, int status, String url)Called when the page status has been changed
public abstract String fieldSubmitted(HTMLComponent htmlC, TextArea ta, String actionURL, String id, String value, int type, String errorMsg)Called whenever a field is submitted to a form.
public abstract String getAutoComplete(HTMLComponent htmlC, String actionURL, String id)Called on form creation and enabled implementations of this method to return a value to preset in a form field.
public abstract int getLinkProperties(HTMLComponent htmlC, String url)Returns properties about the given link to indicate to HTMLComponent how to render it Note that this method is always called NOT on the EDT thread.
public abstract boolean linkClicked(HTMLComponent htmlC, String url)Called when a link is clicked.
public abstract void actionPerformed(ActionEvent evt, HTMLComponent htmlC, HTMLElement element)Called whenever an ActionEvent is triggered in one of the controls in the HTMLComponent For example, button press, checkbox/radiobutton check etc. This method will be called only if HTMLComponent.isEventsEnabled() is true
public abstract void focusGained(Component cmp, HTMLComponent htmlC, HTMLElement element)Called when one of the controls in the HTMLComponent obtained focus This method will be called only if HTMLComponent.isEventsEnabled() is true
public abstract void focusLost(Component cmp, HTMLComponent htmlC, HTMLElement element)Called when one of the controls in the HTMLComponent lost focus This method will be called only if HTMLComponent.isEventsEnabled() is true
public abstract void selectionChanged(int oldSelected, int newSelected, HTMLComponent htmlC, List list, HTMLElement element)Called when the user selects an item in a List inside the HTMLComponent Note: Selection is traversing through the items - once the user has actually decided, an ActionEvent will be sent as well This method will be called only if HTMLCompone…
public abstract void dataChanged(int type, int index, HTMLComponent htmlC, TextField textField, HTMLElement element)Called when the user types in a TextField inside the HTMLComponent This method will be called only if HTMLComponent.isEventsEnabled() is true
public abstract boolean parsingError(int errorId, String tag, String attribute, String value, String description)Called when encountering an error while parsing the HTML document.

Inherited fields

Field details

ERROR_CONNECTING

public static final int ERROR_CONNECTING = 100
Error code denoting that a connection to the resource provider/server could not be made

ERROR_IMAGE_NOT_FOUND

public static final int ERROR_IMAGE_NOT_FOUND = 101
Error code denoting that an image referenced from the HTML was not found

ERROR_IMAGE_BAD_FORMAT

public static final int ERROR_IMAGE_BAD_FORMAT = 102
Error code denoting that an image referenced from the HTML could not be loaded

ERROR_NO_BASE_URL

public static final int ERROR_NO_BASE_URL = 103
Error code denoting that a relative URL was referenced from a document with no base URL (A document that was loaded via setBody/setHTML/setDOM and not via setPage) In this case the return value of parsingError is not considered - parsing continues and the resource at the URL (CSS file/image) is ignored

ERROR_INVALID_TAG_HIERARCHY

public static final int ERROR_INVALID_TAG_HIERARCHY = 104
Error code denoting that a tag contains tags it shouldn’t, or that a tag doesn’t have the parent tag it should have

STATUS_NONE

public static final int STATUS_NONE = -3
This is returned in the page status if no page has been set to the HTMLComponent

STATUS_ERROR

public static final int STATUS_ERROR = -2
The page couldn’t load completely because of parsing errors

STATUS_CANCELLED

public static final int STATUS_CANCELLED = -1
The page loading was cancelled before it could be completed

STATUS_REQUESTED

public static final int STATUS_REQUESTED = 0
The page was requested from the request handler

STATUS_CONNECTED

public static final int STATUS_CONNECTED = 1
The stream was received

STATUS_PARSED

public static final int STATUS_PARSED = 2
The page was parsed

STATUS_DISPLAYED

public static final int STATUS_DISPLAYED = 3
The page was displayed on screen - but at this stage some images and CSS files may still be loading in the background

STATUS_COMPLETED

public static final int STATUS_COMPLETED = 4
The page and all of its referenced images and CSS files were loaded completely

STATUS_REDIRECTED

public static final int STATUS_REDIRECTED = 5
The page was redirected to another URL

FIELD_TEXT

public static final int FIELD_TEXT = 0
A text field

FIELD_PASSWORD

public static final int FIELD_PASSWORD = 1
A password field

ERROR_CSS_ATTRIBUTE_NOT_SUPPORTED

public static final int ERROR_CSS_ATTRIBUTE_NOT_SUPPORTED = 200
Error code denoting that an unsupported CSS attribute (by XHTML-MP 1.0 standards) was found in the HTML or external CSS files

ERROR_CSS_ATTIBUTE_VALUE_INVALID

public static final int ERROR_CSS_ATTIBUTE_VALUE_INVALID = 201
Error code denoting that an invalid attribute value was found in the CSS

ERROR_CSS_NOT_FOUND

public static final int ERROR_CSS_NOT_FOUND = 202
Error code denoting that a CSS file referenced from the HTML or from another external CSS file was not found

ERROR_CSS_NO_BASE_URL

public static final int ERROR_CSS_NO_BASE_URL = 203
Error code denoting that a relative URL was referenced from a document with no base URL (A document that was loaded via setBody/setHTML/setDOM and not via setPage) In this case the return value of parsingError is not considered - parsing continues and the resource at the URL (CSS file/image) is ignored

Method details

titleUpdated

public abstract void titleUpdated(HTMLComponent htmlC, String title)
Called when the page’s title is updated

Parameters

htmlC HTMLComponent
The HTMLComponent that triggered the event
title String
The new title

pageStatusChanged

public abstract void pageStatusChanged(HTMLComponent htmlC, int status, String url)
Called when the page status has been changed

Parameters

htmlC HTMLComponent
The HTMLComponent in which the status change occured
status int
The new status, one of the STATUS_* constants
url String
The URL of the page

fieldSubmitted

public abstract String fieldSubmitted(HTMLComponent htmlC, TextArea ta, String actionURL, String id, String value, int type, String errorMsg)
Called whenever a field is submitted to a form. This can be used to perform sanity checks and/or to store values for auto complete.

Parameters

htmlC HTMLComponent
The HTMLComponent in which this event occured
ta TextArea
The TextArea/TextField of this field
actionURL String
The action URL of the form
id String
The ID of the field
value String
The value entered
type int
The type of the field, one of the FIELD_* constants
errorMsg String
The error message if any error occured (i.e. input validation error) or null if no error occured

Returns

The string to submit to the form (Should return value if nothing changed)

getAutoComplete

public abstract String getAutoComplete(HTMLComponent htmlC, String actionURL, String id)
Called on form creation and enabled implementations of this method to return a value to preset in a form field. This can be used to auto complete previously entered value Note that this method is always called NOT on the EDT thread.

Parameters

htmlC HTMLComponent
The HTMLComponent in which this event occured
actionURL String
The action URL of the form
id String
The ID of the field

Returns

The string to place in the indicated field

getLinkProperties

public abstract int getLinkProperties(HTMLComponent htmlC, String url)
Returns properties about the given link to indicate to HTMLComponent how to render it Note that this method is always called NOT on the EDT thread.

Parameters

htmlC HTMLComponent
The HTMLComponent
url String
The Link URL

Returns

LINK_REGULAR or LINK_VISITED or LINK_FORBIDDEN or a mask of those

linkClicked

public abstract boolean linkClicked(HTMLComponent htmlC, String url)
Called when a link is clicked. This can be used to process links that needs additional/alternate handling than fetching an HTML.

Parameters

htmlC HTMLComponent
The HTMLComponent
url String
The Link URL

Returns

true if regular link processing should continue, false otherwise

actionPerformed

public abstract void actionPerformed(ActionEvent evt, HTMLComponent htmlC, HTMLElement element)
Called whenever an ActionEvent is triggered in one of the controls in the HTMLComponent For example, button press, checkbox/radiobutton check etc. This method will be called only if HTMLComponent.isEventsEnabled() is true

Parameters

evt ActionEvent
The event triggered, the component can be extracted using getSource
htmlC HTMLComponent
The HTMLComponent
element HTMLElement
The element associated with the component that triggered the event

focusGained

public abstract void focusGained(Component cmp, HTMLComponent htmlC, HTMLElement element)
Called when one of the controls in the HTMLComponent obtained focus This method will be called only if HTMLComponent.isEventsEnabled() is true

Parameters

cmp Component
The component that triggered the event
htmlC HTMLComponent
The HTMLComponent
element HTMLElement
The element associated with the component that triggered the event

focusLost

public abstract void focusLost(Component cmp, HTMLComponent htmlC, HTMLElement element)
Called when one of the controls in the HTMLComponent lost focus This method will be called only if HTMLComponent.isEventsEnabled() is true

Parameters

cmp Component
The component that triggered the event
htmlC HTMLComponent
The HTMLComponent
element HTMLElement
The element associated with the component that triggered the event

selectionChanged

public abstract void selectionChanged(int oldSelected, int newSelected, HTMLComponent htmlC, List list, HTMLElement element)
Called when the user selects an item in a List inside the HTMLComponent Note: Selection is traversing through the items - once the user has actually decided, an ActionEvent will be sent as well This method will be called only if HTMLComponent.isEventsEnabled() is true

Parameters

oldSelected int
old selected index in list model
newSelected int
new selected index in list model
htmlC HTMLComponent
The HTMLComponent
list List
The list that triggered the event (Usually a ComboBox but not always)
element HTMLElement
The element associated with the component that triggered the event (Should be TAG_SELECT)

dataChanged

public abstract void dataChanged(int type, int index, HTMLComponent htmlC, TextField textField, HTMLElement element)
Called when the user types in a TextField inside the HTMLComponent This method will be called only if HTMLComponent.isEventsEnabled() is true

Parameters

type int
the type data change; REMOVED, ADDED or CHANGED
index int
item index in a list model
htmlC HTMLComponent
The HTMLComponent
textField TextField
The TextField that triggerd the event
element HTMLElement
The element associated with the component that triggered the event (Should be TAG_INPUT with type text/password)

parsingError

public abstract boolean parsingError(int errorId, String tag, String attribute, String value, String description)
Called when encountering an error while parsing the HTML document. When implementing this, the developer should return true if the error should be ignored and the document needs to be further parsed, or false to stop parsing and issue an error to the user Note that this method is always called NOT on the EDT thread.

Parameters

errorId int
The error ID, one of the ERROR_* constants
tag String
The tag in which the error occured (Can be null for non-tag related errors)
attribute String
The attribute in which the error occured (Can be null for non-attribute related errors)
value String
The value in which the error occured (Can be null for non-value related errors)
description String
A verbal description of the error

Returns

true to continue parsing, false to stop