/** * Checks if a string is a valid definition name. * * @param context The request context. * @param definitionName The name of the definition to find. * @return <code>true</code> if <code>definitionName</code> is a valid * definition name. */ private boolean isValidDefinition(TilesRequestContext context, String definitionName) { try { Definition definition = getDefinition(definitionName, context); return definition != null; } catch (NoSuchDefinitionException nsde) { return false; } catch (DefinitionsFactoryException e) { // TODO, is this the right thing to do? return false; } } }
/** {@inheritDoc} */ public boolean isValidDefinition(String definitionName, Request request) { try { Definition definition = getDefinition(definitionName, request); return definition != null; } catch (NoSuchDefinitionException nsde) { log.debug("Cannot find definition '{}'", definitionName); log.debug("Exception related to the not found definition", nsde); return false; } }
/** {@inheritDoc} */ public void render(String definitionName, Request request) { log.debug("Render request received for definition '{}'", definitionName); Definition definition = getDefinition(definitionName, request); if (definition == null) { throw new NoSuchDefinitionException("Unable to find the definition '" + definitionName + "'"); } render(definition, request); }
/** * Renders the definition with specified name. * * @param request The request context. * @param definitionName The name of the definition to render. * @throws NoSuchDefinitionException If the definition has not been found. * @throws DefinitionsFactoryException If something goes wrong when * obtaining the definition. * @since 2.1.3 */ 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); }
/** {@inheritDoc} */ @Override protected Definition getDefinition(String definitionName, TilesRequestContext request) { Definition retValue = null; String key = getDefinitionsFactoryKey(request); if (key != null) { DefinitionsFactory definitionsFactory = key2definitionsFactory.get(key); if (definitionsFactory != null) { retValue = definitionsFactory.getDefinition(definitionName, request); } } if (retValue == null) { retValue = super.getDefinition(definitionName, request); } return retValue; }