Package org.apache.tiles

Examples of org.apache.tiles.TilesException


    public void render(Attribute attr, Writer writer, Object... requestItems)
        throws TilesException, IOException {
        TilesRequestContext request = getRequestContext(requestItems);

        if (attr == null) {
            throw new TilesException("Cannot render a null attribute");
        }

        if (!isPermitted(request, attr.getRoles())) {
            if (LOG.isDebugEnabled()) {
                LOG.debug("Access to attribute denied.  User not in role '"
                        + attr.getRoles() + "'");
            }
            return;
        }

        AttributeType type = attr.getType();
        if (type == null) {
            type = calculateType(attr, request);
            attr.setType(type);
        }

        switch (type) {
            case OBJECT:
                throw new TilesException(
                    "Cannot insert an attribute of 'object' type");
            case STRING:
                writer.write(attr.getValue().toString());
                break;
            case DEFINITION:
                render(request, attr.getValue().toString());
                break;
            case TEMPLATE:
                request.dispatch(attr.getValue().toString());
                break;
            default: // should not happen
                throw new TilesException(
                        "Unrecognized type for attribute value "
                        + attr.getValue());
        }
    }
View Full Code Here


        } catch (TilesException e) {
            throw e;
        } catch (Exception e) {
            LOG.error("Error rendering tile", e);
            // TODO it would be nice to make the preparerInstance throw a more specific
            throw new TilesException(e.getMessage(), e);
        } finally {
            popContext(request);
        }
    }
View Full Code Here

            return;
        }

        if (attr == null) {
            if (name != null) {
                throw new TilesException("Attribute '" + name + "' not found.");
            } else {
                throw new TilesException("No attribute name or value has been provided.");
            }
        }
        render(attr);
    }
View Full Code Here

            Class<?> contextClass = context.getClass();
            Method getInitParameterMethod =
                contextClass.getMethod("getInitParameter", String.class);
            value = getInitParameterMethod.invoke(context, parameterName);
        } catch (Exception e) {
            throw new TilesException("Unrecognized context.  Is this context"
                    + " a ServletContext, PortletContext, or similar?", e);
        }
        return value == null ? null : value.toString();
    }
View Full Code Here

            while (e.hasMoreElements()) {
                String key = e.nextElement();
                initParameters.put(key, (String) method.invoke(context, key));
            }
        } catch (Exception e) {
            throw new TilesException("Unable to retrieve init parameters."
                    + " Is this context a ServletContext, PortletContext,"
                    + " or similar object?", e);
        }
        return initParameters;
    }
View Full Code Here

            return namedClass.newInstance();
        } catch (ClassNotFoundException e) {
            if (returnNull) {
                return null;
            }
            throw new TilesException(
                    "Unable to resolve factory class: '" + className + "'", e);
        } catch (IllegalAccessException e) {
            throw new TilesException(
                    "Unable to access factory class: '" + className + "'", e);
        } catch (InstantiationException e) {
            throw new TilesException(
                    "Unable to instantiate factory class: '"
                            + className
                            + "'. Make sure that this class has a default constructor",
                    e);
        } finally {
View Full Code Here

            throws TilesException {
        Method method;
        try {
            method = clazz.getMethod(methodName, parameterTypes);
        } catch (SecurityException e) {
            throw new TilesException("Cannot access method '"
                    + methodName + "' in class '" + clazz.getName()
                    + "' for security reasons", e);
        } catch (NoSuchMethodException e) {
            throw new TilesException("The method '"
                    + methodName + "' in class '" + clazz.getName()
                    + "' does not exist", e);
        }
        if (!method.isAccessible()) {
            method.setAccessible(true);
View Full Code Here

    public static Object invokeMethod(Object obj, Method method, Object... args)
            throws TilesException {
        try {
            return method.invoke(obj, args);
        } catch (IllegalArgumentException e) {
            throw new TilesException("The arguments for '"
                    + method.getName() + "' in class '"
                    + obj.getClass().getName() + "' are not valid", e);
        } catch (IllegalAccessException e) {
            throw new TilesException("Cannot access '"
                    + method.getName() + "' in class '"
                    + obj.getClass().getName() + "'", e);
        } catch (InvocationTargetException e) {
            throw new TilesException(
                    "An exception has been thrown inside '" + method.getName()
                    + "' in class '" + obj.getClass().getName() + "'", e);
        }
    }
View Full Code Here

        } catch (TilesException e) {
            throw e;
        } catch (Exception e) {
            LOG.error("Error rendering tile", e);
            // TODO it would be nice to make the preparerInstance throw a more specific
            throw new TilesException(e.getMessage(), e);
        } finally {
            BasicComponentContext.popContext(request);
        }
    }
View Full Code Here

                } else {
                    type = ComponentAttribute.STRING;
                }
            }
            if (type == null) {
                throw new TilesException("Unrecognized type for attribute value "
                    + attr.getValue());
            }
        }
        return type;
    }
View Full Code Here

TOP

Related Classes of org.apache.tiles.TilesException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.