|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.taursys.xml.ComponentFactory com.taursys.html.HTMLComponentFactory
HTMLComponentFactory is used to automate the creation of Components based on
the HTML Document and its Elements. It determines the Component type based
on its element tag "type" attribute and "id" attribute. This class
initializes the tagTable with suggested components for HTML tags in its
constructor by calling the initTagTable
method.
This class provides a Singleton via the getInstance
method. This
is recommended over constructing a new instance.
This class contains two primary methods:
getSuggestedComponents
- for use by design tools.createComponents
- to automatically create and bind
Components
at runtime.
Field Summary |
Fields inherited from class com.taursys.xml.ComponentFactory |
ID_DELIMITER, tagTable, TEMPLATE_NODE |
Constructor Summary | |
HTMLComponentFactory()
Default constructor for HTMLComponentFactory. |
Method Summary | |
protected Component |
createComponentForElement(org.w3c.dom.Element element,
NodeDescriptor nd)
|
protected Component |
createComponentForElement(java.lang.String id,
org.w3c.dom.Element element,
ValueHolder[] holders)
Create a component for given element and set its properties. |
static HTMLComponentFactory |
getInstance()
Get the singleton instance of the HTMLComponentFactory. |
java.util.Vector |
getSuggestedComponents(org.w3c.dom.Element element)
Returns a Vector of suggested Component class names for given Element. |
protected void |
initTagTable()
Initialize the factory's tagTable with suggested components for HTML documents. |
static void |
main(java.lang.String[] args)
|
void |
putTagSuggestion(java.lang.String tagName,
java.lang.Class[] clazzes)
Adds tag with multiple suggested components to tagTable |
Methods inherited from class com.taursys.xml.ComponentFactory |
bindComponent, createComponents, createComponents, getSuggestedComponents, parseBindSyntax, printComponentTree |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public HTMLComponentFactory()
getInstance()
Method Detail |
public static HTMLComponentFactory getInstance()
protected void initTagTable()
Element Tag | Type Attribute | Suggested Component(s) |
center | n/a | com.taursys.xml.TextField |
input | password | com.taursys.html.HTMLInputText |
th | n/a | com.taursys.xml.TextField |
td | n/a | com.taursys.xml.TextField |
code | n/a | com.taursys.xml.TextField |
dt | n/a | com.taursys.xml.TextField |
textarea | n/a | com.taursys.html.HTMLTextArea |
link | n/a | com.taursys.html.HTMLAnchorURL |
input | hidden | com.taursys.html.HTMLInputText |
samp | n/a | com.taursys.xml.TextField |
strike | n/a | com.taursys.xml.TextField |
abbr | n/a | com.taursys.xml.TextField |
big | n/a | com.taursys.xml.TextField |
dd | n/a | com.taursys.xml.TextField |
sup | n/a | com.taursys.xml.TextField |
del | n/a | com.taursys.xml.TextField |
acronym | n/a | com.taursys.xml.TextField |
input | submit | com.taursys.xml.Button, com.taursys.xml.Trigger |
span | n/a | com.taursys.xml.TextField |
sub | n/a | com.taursys.xml.TextField |
var | n/a | com.taursys.xml.TextField |
h6 | n/a | com.taursys.xml.TextField |
h5 | n/a | com.taursys.xml.TextField |
h4 | n/a | com.taursys.xml.TextField |
input | checkbox | com.taursys.html.HTMLCheckBox |
h3 | n/a | com.taursys.xml.TextField |
h2 | n/a | com.taursys.xml.TextField |
thead | n/a | com.taursys.xml.TextField |
h1 | n/a | com.taursys.xml.TextField |
strong | n/a | com.taursys.xml.TextField |
cite | n/a | com.taursys.xml.TextField |
kbd | n/a | com.taursys.xml.TextField |
title | n/a | com.taursys.xml.TextField |
li | n/a | com.taursys.xml.TextField |
small | n/a | com.taursys.xml.TextField |
option | n/a | com.taursys.xml.TextField |
ins | n/a | com.taursys.xml.TextField |
legend | n/a | com.taursys.xml.TextField |
caption | n/a | com.taursys.xml.TextField |
u | n/a | com.taursys.xml.TextField |
pre | n/a | com.taursys.xml.TextField |
s | n/a | com.taursys.xml.TextField |
q | n/a | com.taursys.xml.TextField |
select | n/a | com.taursys.html.HTMLSelect |
p | n/a | com.taursys.xml.TextField |
label | n/a | com.taursys.xml.TextField |
input | text | com.taursys.html.HTMLInputText |
blockquote | n/a | com.taursys.xml.TextField |
i | n/a | com.taursys.xml.TextField |
em | n/a | com.taursys.xml.TextField |
font | n/a | com.taursys.xml.TextField |
tt | n/a | com.taursys.xml.TextField |
b | n/a | com.taursys.xml.TextField |
a | n/a | com.taursys.html.HTMLAnchorURL |
dfn | n/a | com.taursys.xml.TextField |
initTagTable
in class ComponentFactory
public void putTagSuggestion(java.lang.String tagName, java.lang.Class[] clazzes)
tagName
- the tag nameclazzes
- the suggested componentspublic java.util.Vector getSuggestedComponents(org.w3c.dom.Element element)
If the component is an input component, then the TYPE attribute is also used in selecting the right component.
If the Element has an ID, then the com.taursys.xml.DocumentElement Component will be added to the end of the suggestion list.
If the id contains the TEMPLATE_NODE keyword, then a Template will be added to the top of the suggestion list.
If there are no suggested types of Component for the given Element, then an empty Vector will be returned.
Subclasses should override this method if more than the Element tag name is needed to determine the suggested components.
getSuggestedComponents
in class ComponentFactory
element
- to return default Component type for
protected Component createComponentForElement(java.lang.String id, org.w3c.dom.Element element, ValueHolder[] holders)
Create a component for given element and set its properties. Only bound components with id's following a strict id naming convention will be created.
The id must begin with a ValueHolder's alias. It must then be followed by a double-underscore ("__"). Next the propertyName must appear or the keyword "TEMPLATE_NODE". An optional suffix can be added to ensure unique id's (as required by spec). The optional suffix must be separated from the property name by a double-underscore("__"). The following are examples of valid id format:
The alias of the id (first part), must match an alias of a ValueHolder in the given array of ValueHolders, otherwise no Component will be created. The ValueHolder with a matching alias will be set as the new Component's valueHolder.
If the new Component is an AbstractField subclass, then its propertyName will be set to the propertyName of the id (second part). If the given Element has a "name" attribute, the Component's parameter will be set to the value of the "name" attribute.
If the new Component is a Template (or subclass), then only its collectionValueHolder property will be set. The associated ValueHolder for this Component must be a CollectionValueHolder, otherwise no Component will be created.
This method will also attempt to setup the formatting properties for the new Component. This only applies to AbstractField subclasses. The format is extracted from the document within the element's "value" attribute, "href" attribute, or text node. The format must be specified as TYPE:pattern, where TYPE is one of: DATE NUMBER or MSG. The pattern should be a valid pattern for the format type. The following are examples of use:
createComponentForElement
in class ComponentFactory
id
- of Element to create component forelement
- to create component forholders
- the array of ValueHolders for binding
protected Component createComponentForElement(org.w3c.dom.Element element, NodeDescriptor nd)
createComponentForElement
in class ComponentFactory
element
- nd
-
public static void main(java.lang.String[] args)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |