| Method from org.apache.tiles.impl.BasicTilesContainer Detail: |
protected void checkInit() {
if (initialized) {
throw new IllegalStateException("Container allready initialized");
}
}
Determine whether or not the container has been
initialized. Utility method used for methods which
can not be invoked after the container has been
started. |
public void endContext(Object requestItems) {
TilesRequestContext tilesContext = getRequestContext(requestItems);
endContext(tilesContext);
}
|
public Object evaluate(Attribute attribute,
Object requestItems) {
TilesRequestContext request = getRequestContextFactory()
.createRequestContext(context, requestItems);
AttributeEvaluator evaluator = attributeEvaluatorFactory
.getAttributeEvaluator(attribute);
return evaluator.evaluate(attribute, request);
}
|
public TilesApplicationContext getApplicationContext() {
return context;
}
Returns the Tiles application context used by this container. |
public AttributeContext getAttributeContext(Object requestItems) {
TilesRequestContext tilesContext = getRequestContext(requestItems);
return getAttributeContext(tilesContext);
}
|
protected AttributeContext getContext(TilesRequestContext tilesContext) {
ArrayStack< AttributeContext > contextStack = getContextStack(tilesContext);
if (!contextStack.isEmpty()) {
return contextStack.peek();
} else {
return null;
}
}
Get attribute context from request. |
public TilesContextFactory getContextFactory() {
return null;
} Deprecated! Do - not use it, it returns null. Use
#getRequestContextFactory() .
Returns the context factory. |
protected ArrayStack<AttributeContext> getContextStack(TilesRequestContext tilesContext) {
ArrayStack< AttributeContext > contextStack =
(ArrayStack< AttributeContext >) tilesContext
.getRequestScope().get(ATTRIBUTE_CONTEXT_STACK);
if (contextStack == null) {
contextStack = new ArrayStack< AttributeContext >();
tilesContext.getRequestScope().put(ATTRIBUTE_CONTEXT_STACK,
contextStack);
}
return contextStack;
}
Returns the context stack. |
protected Definition getDefinition(String definitionName,
TilesRequestContext request) {
Definition definition =
definitionsFactory.getDefinition(definitionName, request);
return definition;
}
Returns a definition specifying its name. |
public DefinitionsFactory getDefinitionsFactory() {
return definitionsFactory;
}
Returns the definitions factory. |
public PreparerFactory getPreparerFactory() {
return preparerFactory;
}
Returns the preparer factory used by this container. |
protected TilesRequestContextFactory getRequestContextFactory() {
return contextFactory;
}
Returns the request context factory. |
protected List<String> getResourceNames(String resourceString) {
StringTokenizer tokenizer = new StringTokenizer(resourceString, ",");
List< String > filenames = new ArrayList< String >(tokenizer.countTokens());
while (tokenizer.hasMoreTokens()) {
filenames.add(tokenizer.nextToken().trim());
}
return filenames;
}
Parse the resourceString into a list of resource paths
which can be loaded by the application context. |
protected String getResourceString() {
return getResourceString(context.getInitParams());
}
|
protected String getResourceString(Map<String, String> parms) {
String resourceStr = parms.get(DEFINITIONS_CONFIG);
if (resourceStr == null) {
resourceStr = parms.get(LEGACY_DEFINITIONS_CONFIG);
}
if (resourceStr == null) {
resourceStr = "/WEB-INF/tiles.xml";
}
return resourceStr;
}
|
public void init(Map<String, String> initParameters) {
checkInit();
initialized = true;
if (rendererFactory == null) {
throw new IllegalStateException("RendererFactory not specified");
}
if (preparerFactory == null) {
throw new IllegalStateException("PreparerFactory not specified");
}
if (definitionsFactory == null) {
throw new IllegalStateException("DefinitionsFactory not specified");
}
if (attributeEvaluatorFactory == null) {
throw new IllegalStateException("AttributeEvaluatorFactory not specified");
}
if (contextFactory == null) {
throw new IllegalStateException("TilesContextFactory not specified");
}
if (context == null) {
throw new IllegalStateException("TilesApplicationContext not specified");
}
}
Initialize the Container with the given configuration. |
protected void initializeDefinitionsFactory(DefinitionsFactory definitionsFactory,
String resourceString,
Map<String, String> initParameters) {
if (rendererFactory == null) {
throw new IllegalStateException("No RendererFactory found");
}
definitionsFactory.init(initParameters);
if (log.isInfoEnabled()) {
log.info("Tiles2 container initialization complete.");
}
} Deprecated! Do - not use, the Definitions Factory should be initialized by
the Tiles Container Factory.
Initializes a definitions factory. |
public boolean isValidDefinition(String definitionName,
Object requestItems) {
return isValidDefinition(getRequestContext(requestItems), definitionName);
}
|
protected AttributeContext popContext(TilesRequestContext tilesContext) {
ArrayStack< AttributeContext > contextStack = getContextStack(tilesContext);
return contextStack.pop();
}
Pops a context object out of the stack. |
public void prepare(String preparer,
Object requestItems) {
TilesRequestContext requestContext = getRequestContextFactory().createRequestContext(
getApplicationContext(),
requestItems
);
prepare(requestContext, preparer, false);
}
|
protected void pushContext(AttributeContext context,
TilesRequestContext tilesContext) {
ArrayStack< AttributeContext > contextStack = getContextStack(tilesContext);
contextStack.push(context);
}
Pushes a context object in the stack. |
public void render(String definitionName,
Object requestItems) {
TilesRequestContext requestContext = getRequestContextFactory().createRequestContext(
getApplicationContext(),
requestItems
);
render(requestContext, definitionName);
}
|
public void render(Attribute attr,
Object requestItems) throws IOException {
TilesRequestContext requestContext = getRequestContextFactory()
.createRequestContext(getApplicationContext(), requestItems);
render(attr, requestContext);
}
|
protected void render(TilesRequestContext request,
String definitionName) {
if (log.isDebugEnabled()) {
log.debug("Render request recieved for definition '" + definitionName + "'");
}
Definition definition = getDefinition(definitionName, request);
if (definition == null) {
if (log.isWarnEnabled()) {
String message = "Unable to find the definition '" + definitionName + "'";
log.warn(message);
}
throw new NoSuchDefinitionException(definitionName);
}
render(request, definition);
}
Renders the definition with specified name. |
protected void render(TilesRequestContext request,
Definition definition) {
AttributeContext originalContext = getAttributeContext(request);
BasicAttributeContext subContext = new BasicAttributeContext(originalContext);
subContext.inherit(definition);
pushContext(subContext, request);
try {
render(request, subContext);
} finally {
popContext(request);
}
}
Renders the specified definition. |
protected void render(TilesRequestContext request,
AttributeContext attributeContext) {
try {
if (attributeContext.getPreparer() != null) {
prepare(request, attributeContext.getPreparer(), true);
}
render(attributeContext.getTemplateAttribute(), request);
} catch (IOException e) {
throw new CannotRenderException(e.getMessage(), e);
}
}
Renders the specified attribute context. |
public void render(Attribute attr,
Writer writer,
Object requestItems) throws IOException {
render(attr, requestItems);
}
|
public void renderContext(Object requestItems) {
TilesRequestContext request = getRequestContext(requestItems);
AttributeContext attributeContext = getAttributeContext(request);
render(request, attributeContext);
}
|
public void setApplicationContext(TilesApplicationContext context) {
this.context = context;
}
Sets the Tiles application context to use. |
public void setAttributeEvaluatorFactory(AttributeEvaluatorFactory attributeEvaluatorFactory) {
this.attributeEvaluatorFactory = attributeEvaluatorFactory;
}
|
public void setContextFactory(TilesContextFactory contextFactory) {
// Does nothing
} Deprecated! Use -
#setRequestContextFactory(TilesRequestContextFactory) .
Sets the context factory. |
public void setDefinitionsFactory(DefinitionsFactory definitionsFactory) {
checkInit();
this.definitionsFactory = definitionsFactory;
}
Set the definitions factory. This method first ensures
that the container has not yet been initialized. |
public void setPreparerFactory(PreparerFactory preparerFactory) {
this.preparerFactory = preparerFactory;
}
Set the preparerInstance factory. This method first ensures
that the container has not yet been initialized. |
public void setRendererFactory(RendererFactory rendererFactory) {
this.rendererFactory = rendererFactory;
}
Sets the renderer instance factory. |
public void setRequestContextFactory(TilesRequestContextFactory contextFactory) {
checkInit();
this.contextFactory = contextFactory;
}
Sets the request context factory. |
public AttributeContext startContext(Object requestItems) {
TilesRequestContext tilesContext = getRequestContext(requestItems);
return startContext(tilesContext);
}
|