|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectnextapp.echo2.app.Component
echopointng.ComponentEx
echopointng.AbleComponent
echopointng.TemplatePanel
public class TemplatePanel
TemplatePanel is a container that uses a
TemplateLayoutData to render a template of content.
This layout data can itself contained "named" Components and "named" Text Substitutions.
A singleton TemplateDataSource can be used for more than one
TemplatePanel and hence the memory footprint is reduced if
used in this way.
The supplied template implementation reads XHTML template data from a number of different sources including Files, Strings, Resources and JSP pages.
The markup :
<component name="xxx" style="xxx"/>
is used to indicate where in the template a named component will be placed.
The style attribute can contain a CSS statement for setting
component properties.
For example :
<component name="xxx" style="background:red"/>
will set the background of the inserted component to red.
The standard XHTML "controls" markup can also be used also to subsitute components.
<input/><button/>
and
<select/>
can all be used as component subsitution markers.
The markup :
<text name="xxx" />
is used to indicate where text subsitutions will be placed.
Text subsitution can occur within components as well.
For example imagine the markup of the template looks a bit like this
... preceding markup <component name="button1">Button 1 Text
Here</component> and so on ...
If the isInvokeSetText() property is true and the component that maps to the
name 'button1' has a public void setText(String s) method,
then the text inside the component marker, in this case "Button 1 Text Here",
will be placed into the component via its setText() method.
This is only done once when the template is compiled and isStyleApplied() is false. Of course the component in question must have a setText() method.
The source template data need not be in XHTML format however you must compile it into a XHTML DOM Element. For example you could write your own custom XML/XSLT implementation that produced XHTML.
To do this you must provide a TemplateCompiler to the
rendering framework that takes the raw template data and converts it into a
XHTML DOM element.
TemplatePanel is defined as an AbleComponent
and as such has border, inset and mouse cursor support. However there is a
caveat for to this. These properties only take affect if the top level tag in
the the template data source does not provide a style="" attribute. if one is
provided then it takes precedence over the AbleComponent properties
TemplatePanel also support the use of DisplayLayoutData and
ScrollableDisplayLayoutData when used on child components. This allows
the special "style" attributes to be placed within the template around the child component
in question, perhaps to make it a certain size or position is aspecial place.
TemplateDataSource,
TemplateTextSubstitution,
DisplayLayoutData,
ScrollableDisplayLayoutData,
Serialized Form| Field Summary | |
|---|---|
static java.lang.String |
PROPERTY_EXCEPTION_ON_FAILURE
|
static java.lang.String |
PROPERTY_INVOKE_SETTEXT
|
static java.lang.String |
PROPERTY_TEMPLATE_DATA_SOURCE
|
static java.lang.String |
PROPERTY_TEMPLATE_TEXT_SUBSTITUTION
|
| Fields inherited from class echopointng.ComponentEx |
|---|
PROPERTY_HIDDEN |
| Fields inherited from interface echopointng.able.AccessKeyable |
|---|
PROPERTY_ACCESS_KEY |
| Fields inherited from interface echopointng.able.Borderable |
|---|
PROPERTY_BORDER |
| Fields inherited from interface echopointng.able.MouseCursorable |
|---|
CURSOR_AUTO, CURSOR_CROSSHAIR, CURSOR_CUSTOM_URI, CURSOR_DEFAULT, CURSOR_E_RESIZE, CURSOR_HELP, CURSOR_MOVE, CURSOR_N_RESIZE, CURSOR_NE_RESIZE, CURSOR_NW_RESIZE, CURSOR_POINTER, CURSOR_S_RESIZE, CURSOR_SE_RESIZE, CURSOR_SW_RESIZE, CURSOR_TEXT, CURSOR_W_RESIZE, CURSOR_WAIT, PROPERTY_MOUSE_CURSOR, PROPERTY_MOUSE_CURSOR_URI |
| Fields inherited from interface echopointng.able.Insetable |
|---|
DEFAULT_INSETS, DEFAULT_OUTSETS, PROPERTY_INSETS, PROPERTY_OUTSETS |
| Fields inherited from interface echopointng.able.Widthable |
|---|
PROPERTY_WIDTH |
| Fields inherited from interface echopointng.able.Heightable |
|---|
PROPERTY_HEIGHT |
| Fields inherited from interface echopointng.able.ToolTipable |
|---|
PROPERTY_TOOL_TIP_TEXT |
| Constructor Summary | |
|---|---|
TemplatePanel()
Constructs a TemplatePanel with no template data as yet. |
|
TemplatePanel(TemplateDataSource tds)
Constructs a TemplatePanel with the specified
TemplateDataSource. |
|
| Method Summary | |
|---|---|
void |
addNamedComponent(Component component,
java.lang.String componentName)
Adds a component to the TemplatePanel with the associated
name which can the be references from the template data. |
java.lang.String |
getComponentName(Component component)
Returns the name associated with the component or null if it cant be found. |
Component |
getNamedComponent(java.lang.String componentName)
Returns a component associated with the name or null if it cant be found. |
java.lang.String[] |
getNamedComponents()
|
TemplateDataSource |
getTemplateDataSource()
Returns the TemplateDataSource which contains the template data. |
TemplateTextSubstitution |
getTemplateTextSubstitution()
Returns the TemplateTextSubstitution in place. |
boolean |
isExceptionOnFailure()
The default value is false. |
boolean |
isInvokeSetText()
Returns true if the text of a component marker is the template is placed into the component via its setTextMethod. |
boolean |
isStyleApplied()
Returns true if the style declarations from the template data have been applied. |
void |
remove(Component c)
Removes the specified child Component from this
Component. |
void |
removeNamedComponent(java.lang.String componentName)
Removes a named component from the TemplatePanel that was
previously added via the addNamedComponent() method. |
void |
setExceptionOnFailure(boolean newValue)
If set to true, then if the template data cannot be compiled, a a runtime exception will be thrown. |
void |
setInvokeSetText(boolean newValue)
Controls if the text of a component marker is the template is placed into the component via its setTextMethod. |
void |
setStyleApplied(boolean styleApplied)
Controls whether style declarations in the template data have been applied or not. |
void |
setTemplateDataSource(TemplateDataSource templateDataSource)
Sets the TemplateDataSource to be used |
void |
setTemplateTextSubstitution(TemplateTextSubstitution textSubstitution)
Sets the TemplateTextSubstitution to be used to substitute 'named' text into the template data |
void |
validate()
A life-cycle method invoked before the component is rendered to ensure it is in a valid state. |
| Methods inherited from class echopointng.AbleComponent |
|---|
getAccessKey, getBorder, getHeight, getInsets, getMouseCursor, getMouseCursorURI, getOutsets, getToolTipText, getWidth, setAccessKey, setBorder, setHeight, setInsets, setMouseCursor, setMouseCursorURI, setOutsets, setToolTipText, setWidth |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface echopointng.able.Delegateable |
|---|
getRenderProperty, getRenderProperty |
| Methods inherited from interface echopointng.able.Delegateable |
|---|
getRenderProperty, getRenderProperty |
| Methods inherited from interface echopointng.able.Delegateable |
|---|
getRenderProperty, getRenderProperty |
| Methods inherited from interface echopointng.able.Delegateable |
|---|
getRenderProperty, getRenderProperty |
| Methods inherited from interface echopointng.able.Delegateable |
|---|
getRenderProperty, getRenderProperty |
| Methods inherited from interface echopointng.able.Delegateable |
|---|
getRenderProperty, getRenderProperty |
| Field Detail |
|---|
public static final java.lang.String PROPERTY_EXCEPTION_ON_FAILURE
public static final java.lang.String PROPERTY_INVOKE_SETTEXT
public static final java.lang.String PROPERTY_TEMPLATE_DATA_SOURCE
public static final java.lang.String PROPERTY_TEMPLATE_TEXT_SUBSTITUTION
| Constructor Detail |
|---|
public TemplatePanel()
TemplatePanel with no template data as yet.
public TemplatePanel(TemplateDataSource tds)
TemplatePanel with the specified
TemplateDataSource.
tds - -
the source for the template data.| Method Detail |
|---|
public void addNamedComponent(Component component,
java.lang.String componentName)
TemplatePanel with the associated
name which can the be references from the template data.
component - the component to addcomponentName - -
the name to use when referencing this component in the
template data.public java.lang.String getComponentName(Component component)
component - -
the component associated with the name
public Component getNamedComponent(java.lang.String componentName)
componentName - -
the name associated with the component
public java.lang.String[] getNamedComponents()
TemplatePanel.public TemplateDataSource getTemplateDataSource()
public TemplateTextSubstitution getTemplateTextSubstitution()
public boolean isExceptionOnFailure()
public boolean isInvokeSetText()
public boolean isStyleApplied()
public void remove(Component c)
ComponentComponent from this
Component.
All Component remove operations use this method to
remove Components. Components that require
notification of all child removals should
override this method (while ensuring to call the superclass'
implementation).
remove in class Componentc - the child Component to removeComponent.remove(nextapp.echo2.app.Component)public void removeNamedComponent(java.lang.String componentName)
TemplatePanel that was
previously added via the addNamedComponent() method.
componentName - -
the name of the componentpublic void setExceptionOnFailure(boolean newValue)
Some people prefer exceptions and "defined" error behaviour. Others prefer soft failures and the system to keep on running.
newValue - -
the new failure valuepublic void setInvokeSetText(boolean newValue)
The markup of the template might look like this
...
preceding markup <component name="button1">Button 1 Text Here</component> and so on
...
If this property is true and the component that maps to the name button1 has a public void setText(String s) method, then the text inside the component marker, in this case "Button 1 Text Here", will be placed into the component via its setText() method.
This is only done once when the template is compiled and isStyleApplied() is false. Of course the component in question must have a setText() method.
newValue - -
the new boolean valuepublic void setStyleApplied(boolean styleApplied)
styleApplied - -
The newValue to set.public void setTemplateDataSource(TemplateDataSource templateDataSource)
templateDataSource - the TemplateDataSource to be usedpublic void setTemplateTextSubstitution(TemplateTextSubstitution textSubstitution)
textSubstitution - -
The newValue to set.public void validate()
Componentsuper.validate()
out of convention.
validate in class ComponentComponent.validate()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||