|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectechoxul.view.ViewLocator
This is the abstract base class for accessing/resolving View instances by symbolic names. It is accessed through a singleton-like mechanism where the instance is retrieved from the EchoInstance attributes collection with the name ViewCache.ATTRIBUTE_NAME.
Note that this scheme means that a new ViewCache will be instantiated for every user. View instances were intended to be used by all sessions in a server and recreating them for every user is wasteful of resources. To get around this, the developer must explicitly initialize the EchoInstance singleton to a ViewCache that is shared across the entire application.
If a ViewCache has not been explicitly set, the first call to the getInstance(EchoInstance) method will result in a limited ViewCache being created which is only capable of loading resources from the class path (ie. via Class.getResource()). More complicated schems that use web or file system resources need to be explicitly set during server startup.
| Field Summary | |
static java.lang.String |
ATTRIBUTE_NAME
The name of the attribute in EchoInstance where the singleton is stored. |
| Constructor Summary | |
ViewLocator()
|
|
| Method Summary | |
static ViewLocator |
getInstance(nextapp.echo.EchoInstance echoInstance)
Return the singleton instance, creating a default one if necessary |
abstract View |
lookupView(java.lang.Class clazz)
Similar to lookupView(String) except that it converts the given class into a path and looks up the view with that path. |
abstract View |
lookupView(java.lang.String path)
Looks up a (potentially cached) view from the list of ViewResolvers registered with this instance. |
static void |
setInstance(nextapp.echo.EchoInstance echoInstance,
ViewLocator viewCache)
Call at application startup to initialize an EchoInstance with a singleton ViewCache. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final java.lang.String ATTRIBUTE_NAME
| Constructor Detail |
public ViewLocator()
| Method Detail |
public static ViewLocator getInstance(nextapp.echo.EchoInstance echoInstance)
echoInstance -
public static void setInstance(nextapp.echo.EchoInstance echoInstance,
ViewLocator viewCache)
echoInstance - viewCache -
public abstract View lookupView(java.lang.String path)
throws ViewNotFoundException
TODO: Fully document this method
path - The resolver specific path string
ViewNotFoundException - if the view cannot be found
public abstract View lookupView(java.lang.Class clazz)
throws ViewNotFoundException
clazz - The class to lookup.
ViewNotFoundException - if the view cannot be found
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||