EchoPoint
1.0

echopoint.layout
Class JspTemplateLayoutManager

java.lang.Object
  extended byechopoint.layout.AbstractLayoutManager
      extended byechopoint.layout.JspTemplateLayoutManager
All Implemented Interfaces:
ComponentMapper, LayoutManager, PropertyManagerOwner, java.io.Serializable

public class JspTemplateLayoutManager
extends AbstractLayoutManager
implements ComponentMapper, PropertyManagerOwner

Generates content from a JSP page and adds it into the Echo framework. Echo components can also be added to the JSP. The JSP can be used for HTML templating, as a HTML layout container, or any sort of dynamic content generation.

It is useful for rendering content that has complex layout that is best done in HTML. It is also useful when reusing existing JSP work.

Note this layout manager only allows for JSP fragements. This means the main body is still generated by a top level Echo container.

This layout manager can be used for generating dynamic html content but it can also be used to layout other Echo components within its html/jsp.

Any Echo component added to this layout manager can be referenced and laid out with a JSP tag (the EchoComponentTag) via the a tag as in

 <%@ taglib uri="/WEB-INF/echopointtags.tld" prefix="echo" %>
 <echo:component name="xxx"/>
 

The JSP page can be fed bean objects that are put into JSP request scope. The bean objects can be static or dynamically generated on every rendering.

One way is to provide a single static bean. With a static bean, one can only send one single bean to the JSP and the bean can only be changed by the component using the setBean method.

Another way is to use to use a Map of bean objects. This allows for more than one static bean to be placed into the JSP request scope. You can also use the addBean(bean,beanName) method to add beans to a default Map.

Finally the JspBeanGenerator interface can be used to create dynamically generated beans values. Dynamically generated beans allow for one or more beans to be passed into the JSP. The implementing JspBeanGenerator can then choose to have there content cached (ie set once) or generated on the fly every time the JSP is rendered.

JspTemplateLayoutManager supports setting properties of the component via a CSS like style setting :

 <echo:component name="comp1" style="background : #ff0000; font : verdana,bold,9; foreground : yellow">
 

This uses the EchoPoint CSS support to each of the component properties via entries in the style attribute. For more information on this see

Author:
Sam Taha (tahasam@yahoo.com)
See Also:
and @see echopoint.stylesheet.CssStyleSheet.

, Serialized Form


Field Summary
 
Fields inherited from class echopoint.layout.AbstractLayoutManager
componentMap, layoutManageableWR
 
Constructor Summary
JspTemplateLayoutManager(java.lang.String path)
          This constuctor will allow for multiple beans to be passed to the JSP using the addJspBeanGenerator methods.
JspTemplateLayoutManager(java.lang.String path, java.lang.Object bean, java.lang.String beanName)
          This constuctor allows for only one bean to be passed the JSP.
 
Method Summary
 void addBean(java.lang.Object bean, java.lang.String beanName)
          Adds a bean to the JSP LayoutManager mapped by beanName.
 void addJspBeanGenerator(JspBeanGenerator beanGen, java.lang.String beanName)
          Add a new JspBeanGenerator that will be passed to the JSP.
 void addLayoutComponent(nextapp.echo.Component component, java.lang.Object constraints)
          Add a Component that can be layed out in the JSP page using the EchoComponentTag.
static void addPropertyManager(PropertyManager p)
          Adds a PropertyManager to the list of available PropertyManagers.
 java.lang.Object getBean()
          Get bean being passed to JSP.
 java.lang.Object getBean(java.lang.String beanName)
          Returns a bean from the internal bean map with the specified bean name.
 java.lang.String getBeanName()
          Name of bean being passed to JSP.
 java.util.Map getBeans()
          Returns a Map of bean objects that have been added to the JSP LayoutManager
 CompilationContext getCompilationContext()
          Returns the CompilationContext in use by this JspTemplateLayoutManager for the current page.
 nextapp.echo.Component getComponent(java.lang.String name)
          Returns a Component based on the name given.
 java.util.Map getJspBeanGenerators()
          Returns a Map of all the JspBeanGenerators in the layout manager
 java.lang.String getPath()
          Location of the JSP file.
 PropertyManager getPropertyManager(java.lang.Class clazz)
          Called to get a ProperyManagerfor a given clazz of Component
 boolean isLoudErrorsUsed()
          This returns true if "loud" error messages are to be used during template compilation.
 boolean isPropertiesUsed()
          Returns true if the Component properties can be set within the JSP echo tag.
 void removeAllBeans()
          Remove all the Beans from the bean Map.
 void removeAllJspBeanGenerator()
          Remove all the JspBeanGenerator objects in ths component.
 void removeBean(java.lang.String beanName)
          Removes a bean from the bean Map via the specified key
 void removeJspBeanGenerator(java.lang.String beanName)
          Remove the specified the JspBeanGenerator.
 void setBean(java.lang.Object bean)
          Set/Change the bean that the JSP will be using.
 void setBeans(java.util.Map beanMap)
          Sets the Map of bean names to bean objects via the specified Map.
 void setLoudErrorsUsed(boolean b)
          Controls whether loud error messages are to be used during template compilation.
 void setPath(java.lang.String path)
          Set/Change the location of the JSP file.
 void setPropertiesUsed(boolean b)
          Controls whether Component properties can be set within the JSP echo tag.
 
Methods inherited from class echopoint.layout.AbstractLayoutManager
getComponent, getComponentMap, getContraints, getLayoutManageable, invalidateLayout, removeLayoutComponent, setLayoutManageable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JspTemplateLayoutManager

public JspTemplateLayoutManager(java.lang.String path)
This constuctor will allow for multiple beans to be passed to the JSP using the addJspBeanGenerator methods. JspBeanGenerators can be added removed as needed.

Parameters:
path - Location of the JSP file.

JspTemplateLayoutManager

public JspTemplateLayoutManager(java.lang.String path,
                                java.lang.Object bean,
                                java.lang.String beanName)
This constuctor allows for only one bean to be passed the JSP. The bean can be reset using the setBean method.

Parameters:
path - Location of the JSP file.
bean - JavaBean or Array/Collection of JavaBeans to be used in JSP.
beanName - Name that will be used within the JSP to read the bean from request scope.
Method Detail

addLayoutComponent

public void addLayoutComponent(nextapp.echo.Component component,
                               java.lang.Object constraints)
Add a Component that can be layed out in the JSP page using the EchoComponentTag.

This method is not intended to be called by any other than an LayoutManageable during Component add().

Specified by:
addLayoutComponent in interface LayoutManager
Overrides:
addLayoutComponent in class AbstractLayoutManager

getBean

public java.lang.Object getBean()
Get bean being passed to JSP. This should not be used if the JspBeanGenerator interface is being used instead.


getBeanName

public java.lang.String getBeanName()
Name of bean being passed to JSP. This should not be used if the JspBeanGenerator interface is being used instead.


getBeans

public java.util.Map getBeans()
Returns a Map of bean objects that have been added to the JSP LayoutManager

Returns:
a Map of beans or null

getBean

public java.lang.Object getBean(java.lang.String beanName)
Returns a bean from the internal bean map with the specified bean name.

Parameters:
beanName - - the key to used to retrive the bean
Returns:
a bean value or null if it cant be found.

getJspBeanGenerators

public java.util.Map getJspBeanGenerators()
Returns a Map of all the JspBeanGenerators in the layout manager

Returns:
a Map of all the JspBeanGenerators in the layout manager

getPath

public java.lang.String getPath()
Location of the JSP file.


removeAllJspBeanGenerator

public void removeAllJspBeanGenerator()
Remove all the JspBeanGenerator objects in ths component.


removeJspBeanGenerator

public void removeJspBeanGenerator(java.lang.String beanName)
Remove the specified the JspBeanGenerator.


removeBean

public void removeBean(java.lang.String beanName)
Removes a bean from the bean Map via the specified key

Parameters:
beanName - - the name of the bean to remove

removeAllBeans

public void removeAllBeans()
Remove all the Beans from the bean Map.


setBean

public void setBean(java.lang.Object bean)
Set/Change the bean that the JSP will be using.


setBeans

public void setBeans(java.util.Map beanMap)
Sets the Map of bean names to bean objects via the specified Map.

Parameters:
beanMap - - the new Map of bean names to bean objects

addJspBeanGenerator

public void addJspBeanGenerator(JspBeanGenerator beanGen,
                                java.lang.String beanName)
Add a new JspBeanGenerator that will be passed to the JSP.

Parameters:
beanGen - JspBeanGenerator to be used in the JSP.
beanName - Name that will be used within the JSP to read the bean from request scope.

addBean

public void addBean(java.lang.Object bean,
                    java.lang.String beanName)
Adds a bean to the JSP LayoutManager mapped by beanName. The beans will be placed in the JSP request scope.

Parameters:
beanName - - the name of the bean
bean - - the bean value

setPath

public void setPath(java.lang.String path)
Set/Change the location of the JSP file.


addPropertyManager

public static final void addPropertyManager(PropertyManager p)
Adds a PropertyManager to the list of available PropertyManagers.


getComponent

public nextapp.echo.Component getComponent(java.lang.String name)
Description copied from interface: ComponentMapper
Returns a Component based on the name given.

Specified by:
getComponent in interface ComponentMapper
See Also:
ComponentMapper.getComponent(java.lang.String)

getPropertyManager

public PropertyManager getPropertyManager(java.lang.Class clazz)
Description copied from interface: PropertyManagerOwner
Called to get a ProperyManagerfor a given clazz of Component

Specified by:
getPropertyManager in interface PropertyManagerOwner
See Also:
PropertyManagerOwner.getPropertyManager(Class)

getCompilationContext

public CompilationContext getCompilationContext()
Returns the CompilationContext in use by this JspTemplateLayoutManager for the current page.

This method is intended for use between the template compiling mechanism and hence is not for general consumption

Returns:
CompilationContext - the one in use

isPropertiesUsed

public boolean isPropertiesUsed()
Returns true if the Component properties can be set within the JSP echo tag.


setPropertiesUsed

public void setPropertiesUsed(boolean b)
Controls whether Component properties can be set within the JSP echo tag.


isLoudErrorsUsed

public boolean isLoudErrorsUsed()
This returns true if "loud" error messages are to be used during template compilation.

Returns:
true if lound error messages are to be displayed

setLoudErrorsUsed

public void setLoudErrorsUsed(boolean b)
Controls whether loud error messages are to be used during template compilation.


EchoPoint
1.0