|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.wings.SAbstractLayoutManager
org.wings.STemplateLayout
public class STemplateLayout
Static layout manager that uses template files to arrange components.
Like any other layout manager it allows to place arbitrary elements, but you can write a simple HTML-page being the template for your container component. Though we encourage the use of the dynamic layout managers, this layout manager can be very useful in realising the main page layout of your web application. To use this layout manager you have to define a template file required by the STemplateLayout instance. Inside this template file you can insert inside your custom HTML code desired wingS objects using tags like<input name="compname">
or
<object name="compname"></object>
The name attribute of these input or object tag is the name
you have to use as layout constraint when you add the desired component to the
template layout managed SContainer:
panel.add(new SLabel("a test label), "compname"));
Besides this simple inlining mechanism the STemplateLayout manager has also another
very powerful feature: Specific components bean attributes can be overwritten by
specific optional inline attributes attached to your object html tags i.e. like
<object name="compname" background="#ff0000" text="new text"></object>
Please refer to javadoc of PropertyManager for more information on this feature.
Sample template file:
<HTML><BODY>
Name der Person: <COMPONENT NAME=NAME><BR>
Vorname der Person: <COMPONENT NAME=VORNAME ICON="vorname.gif"><BR>
Wohnort der Person: <COMPONENT NAME=WOHNORT><BR>
</BODY></HTML>
templateContainer.setLayout(new STemplateLayout("templatefile"));
templateContainer.addComponent(new SLabel("Haaf"), "NAME");
templateContainer.addComponent(new SButton("Armin"), "VORNAME");
templateContainer.addComponent(new SLabel("Neu-Ulm"), "WOHNORT");
PropertyManager,
Serialized Form| Field Summary | |
|---|---|
protected HashMap |
components
Abstraction of the template source (file, resource, ..) |
protected PageParser |
pageParser
PageParser to use |
| Fields inherited from class org.wings.SAbstractLayoutManager |
|---|
border, cg, container, preferredSize |
| Fields inherited from interface org.wings.SConstants |
|---|
BASELINE, BLOCK_ALIGN, BOTTOM, BOTTOM_ALIGN, CENTER, CENTER_ALIGN, HORIZONTAL, JUSTIFY, LEFT, LEFT_ALIGN, NO_ALIGN, RIGHT, RIGHT_ALIGN, TOP, TOP_ALIGN, UID_DIVIDER, VERTICAL |
| Constructor Summary | |
|---|---|
STemplateLayout()
|
|
STemplateLayout(File tmplFile)
Read the template from a file. |
|
STemplateLayout(String tmplFileName)
Open a template from a file with the given name. |
|
STemplateLayout(TemplateSource source)
Create a TemplateLayout that reads its content from the generic TemplateSource. |
|
STemplateLayout(URL url)
Read the template from an URL. |
|
| Method Summary | |
|---|---|
void |
addComponent(SComponent c,
Object constraint,
int index)
add a component with the given constraint. |
static void |
addPropertyManager(PropertyManager p)
Adds a PropertyManager. |
SComponent |
getComponent(String name)
returns a map of the constraint/component. |
PageParser |
getPageParser()
Retrieve the PageParser of this instance |
static PropertyManager |
getPropertyManager(Class c)
Determines appropriate property manager for the given SComponent or derived class. |
TemplateSource |
getTemplateSource()
Returns the source of the template layout. |
void |
removeComponent(SComponent comp)
removes the given component. |
static PropertyManager |
removePropertyManager(Class supportedComponentClass)
Deregisters a property manager for a given component class to be able to replace it. |
void |
setPageParser(PageParser pageParser)
Set the PageParser for this instance |
void |
setTemplate(File templateFile)
Set the template to the template stored in the given file. |
void |
setTemplate(String templateFileName)
Set the template to the template given as file name. |
void |
setTemplate(TemplateSource source)
Sets the template from the DataSource. |
void |
setTemplate(URL templateURL)
Set the template to the template which can be retrieved from the given URL. |
| Methods inherited from class org.wings.SAbstractLayoutManager |
|---|
getBorder, getCG, getContainer, getPreferredSize, setBorder, setCG, setContainer, setPreferredSize, updateCG, write |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected HashMap components
protected transient PageParser pageParser
| Constructor Detail |
|---|
public STemplateLayout()
public STemplateLayout(TemplateSource source)
TemplateSource. The template source can be implemented
to be read from any source you want to, e.g. database BLOBs. Whenever
the source changes (i.e. lastModified() returns a different
modification time the last time this source has been parsed), the
template is reparsed.
source - the TemplateSource this template is to be read from.
public STemplateLayout(String tmplFileName)
throws IOException
tmplFileName - the filename to read the file from.
IOException
public STemplateLayout(File tmplFile)
throws IOException
tmplFile - the File to read the template from.
IOException
public STemplateLayout(URL url)
throws IOException
url - the URL to read the template from.
IOException| Method Detail |
|---|
public static final PropertyManager getPropertyManager(Class c)
public static final void addPropertyManager(PropertyManager p)
public static final PropertyManager removePropertyManager(Class supportedComponentClass)
supportedComponentClass - Target class as in PropertyManager.getSupportedClasses()
public void setTemplate(String templateFileName)
throws IOException
IOException
public void setTemplate(File templateFile)
throws IOException
IOException
public void setTemplate(URL templateURL)
throws IOException
IOExceptionpublic void setTemplate(TemplateSource source)
source - the source this template is to be read.TemplateSource
public void addComponent(SComponent c,
Object constraint,
int index)
c - the component to be addedconstraint - the string describing thepublic void removeComponent(SComponent comp)
comp - the component to be removed.public SComponent getComponent(String name)
public TemplateSource getTemplateSource()
setTemplate(TemplateSource)public PageParser getPageParser()
public void setPageParser(PageParser pageParser)
pageParser - the new PageParser
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||