Package org.thymeleaf.exceptions

Examples of org.thymeleaf.exceptions.TemplateProcessingException


        if (leftNumberValue != null && rightNumberValue != null) {
            // Addition will act as a mathematical 'plus'
            return leftNumberValue.subtract(rightNumberValue);
        }
       
        throw new TemplateProcessingException(
            "Cannot execute subtraction: operands are \"" + LiteralValue.unwrap(leftValue) + "\" and \"" + LiteralValue.unwrap(rightValue) + "\"");
       
    }
View Full Code Here


        }
        if (expression instanceof GenericTokenExpression) {
            return GenericTokenExpression.executeGenericToken(processingContext, (GenericTokenExpression) expression, expContext);
        }

        throw new TemplateProcessingException("Unrecognized simple expression: " + expression.getClass().getName());
       
    }
View Full Code Here

     */
    public static IStandardExpressionParser getExpressionParser(final Configuration configuration) {
        final Object parser =
                configuration.getExecutionAttributes().get(STANDARD_EXPRESSION_PARSER_ATTRIBUTE_NAME);
        if (parser == null || (!(parser instanceof IStandardExpressionParser))) {
            throw new TemplateProcessingException(
                    "No Standard Expression Parser has been registered as an execution argument. " +
                    "This is a requirement for using Standard Expressions, and might happen " +
                    "if neither the Standard or the SpringStandard dialects have " +
                    "been added to the Template Engine and none of the specified dialects registers an " +
                    "attribute of type " + IStandardExpressionParser.class.getName() + " with name " +
View Full Code Here

     */
    public static IStandardVariableExpressionEvaluator getVariableExpressionEvaluator(final Configuration configuration) {
        final Object expressionEvaluator =
                configuration.getExecutionAttributes().get(STANDARD_VARIABLE_EXPRESSION_EVALUATOR_ATTRIBUTE_NAME);
        if (expressionEvaluator == null || (!(expressionEvaluator instanceof IStandardVariableExpressionEvaluator))) {
            throw new TemplateProcessingException(
                    "No Standard Variable Expression Evaluator has been registered as an execution argument. " +
                    "This is a requirement for using Standard Expressions, and might happen " +
                    "if neither the Standard or the SpringStandard dialects have " +
                    "been added to the Template Engine and none of the specified dialects registers an " +
                    "attribute of type " + IStandardVariableExpressionEvaluator.class.getName() + " with name " +
View Full Code Here

     */
    public static IStandardConversionService getConversionService(final Configuration configuration) {
        final Object conversionService =
                configuration.getExecutionAttributes().get(STANDARD_CONVERSION_SERVICE_ATTRIBUTE_NAME);
        if (conversionService == null || (!(conversionService instanceof IStandardConversionService))) {
            throw new TemplateProcessingException(
                    "No Standard Conversion Service has been registered as an execution argument. " +
                    "This is a requirement for using Standard Expressions, and might happen " +
                    "if neither the Standard or the SpringStandard dialects have " +
                    "been added to the Template Engine and none of the specified dialects registers an " +
                    "attribute of type " + IStandardConversionService.class.getName() + " with name " +
View Full Code Here

        final AssignationSequence assignations =
                AssignationUtils.parseAssignationSequence(
                        configuration, arguments, attributeValue, false /* no parameters without value */);
        if (assignations == null) {
            throw new TemplateProcessingException(
                    "Could not parse value as attribute assignations: \"" + attributeValue + "\"");
        }

        Arguments assignationExecutionArguments = arguments;

        final Map<String,Object> newLocalVariables = new HashMap<String,Object>(assignations.size() + 1, 1.0f);
        for (final Assignation assignation : assignations) {
           
            final IStandardExpression leftExpr = assignation.getLeft();
            final Object leftValue = leftExpr.execute(configuration, assignationExecutionArguments);

            final IStandardExpression rightExpr = assignation.getRight();
            final Object rightValue = rightExpr.execute(configuration, assignationExecutionArguments);

            final String newVariableName = (leftValue == null? null : leftValue.toString());
            if (StringUtils.isEmptyOrWhitespace(newVariableName)) {
                throw new TemplateProcessingException(
                        "Variable name expression evaluated as null or empty: \"" + leftExpr + "\"");
            }

            // Creating a new Arguments object allows the reuse of variables in, for example, th:with expressions.
            assignationExecutionArguments =
View Full Code Here

            logger.trace("[THYMELEAF][{}] Evaluating variable expression: \"{}\"", TemplateEngine.threadIndex(), expression.getStringRepresentation());
        }
       
        final String exp = expression.getExpression();
        if (exp == null) {
            throw new TemplateProcessingException(
                    "Variable expression is null, which is not allowed");
        }

        final StandardExpressionExecutionContext evalExpContext =
            (expression.getConvertToString()? expContext.withTypeConversion() : expContext.withoutTypeConversion());
View Full Code Here

       
        Object leftValue = expression.getLeft().execute(configuration, processingContext, expContext);
        Object rightValue = expression.getRight().execute(configuration, processingContext, expContext);

        if (leftValue == null || rightValue == null) {
            throw new TemplateProcessingException(
                    "Cannot execute GREATER THAN comparison: operands are \"" + LiteralValue.unwrap(leftValue) + "\" and \"" + LiteralValue.unwrap(rightValue) + "\"");
        }

        leftValue = LiteralValue.unwrap(leftValue);
        rightValue = LiteralValue.unwrap(rightValue);

        Boolean result = null;

        final BigDecimal leftNumberValue = EvaluationUtil.evaluateAsNumber(leftValue);
        final BigDecimal rightNumberValue = EvaluationUtil.evaluateAsNumber(rightValue);
       
        if (leftNumberValue != null && rightNumberValue != null) {
            result = Boolean.valueOf(leftNumberValue.compareTo(rightNumberValue) == 1);
        } else {
            if (leftValue != null && rightValue != null &&
                    leftValue.getClass().equals(rightValue.getClass()) &&
                    Comparable.class.isAssignableFrom(leftValue.getClass())) {
                result = Boolean.valueOf(((Comparable<Object>)leftValue).compareTo(rightValue) > 0);
            } else {
                throw new TemplateProcessingException(
                        "Cannot execute GREATER THAN from Expression \"" +
                        expression.getStringRepresentation() + "\". Left is \"" +
                        leftValue + "\", right is \"" + rightValue + "\"");
            }
        }
View Full Code Here

    @Override
    public ProcessorResult processTextNode(final Arguments arguments, final AbstractTextNode textNode) {
       
        if (!textNode.getProcessTextNodes()) {
            throw new TemplateProcessingException("Cannot execute text inlining processor: Text processors are not active");
        }
       
        final Object inliner = arguments.getLocalVariable(StandardDialect.INLINER_LOCAL_VARIABLE);
        if (inliner == null) {
            if (this.logger.isTraceEnabled()) {
                this.logger.trace("[THYMELEAF][{}][{}] Will not process Text node as inline: no inliner has been set. " +
                        "Please note that setting the 'processOnlyElementNodes' flag to false at a high level in the DOM " +
                        "tree (like for example using " + ProcessAllNodesDocumentProcessor.class.getName() + ") can reduce " +
                    "processing performance in templates with a big amount of Text nodes. Consider setting this flag " +
                        "back to true at some point in your DOM tree to reduce this effect.",
                        new Object[] {TemplateEngine.threadIndex(), arguments.getTemplateName()});
            }
            return ProcessorResult.OK;
        }
        if (!(inliner instanceof IStandardTextInliner)) {
            throw new TemplateProcessingException("Cannot execute text inlining processor: Inliner set does not implement " + IStandardTextInliner.class.getName() +
                    " (it is an object of class " + inliner.getClass().getName() + ")");
        }
       
        ((IStandardTextInliner)inliner).inline(arguments, textNode);
        return ProcessorResult.OK;
View Full Code Here

        final AssignationSequence assignations =
                AssignationUtils.parseAssignationSequence(
                    configuration, arguments, attributeValue, false /* no parameters without value */);
        if (assignations == null) {
            throw new TemplateProcessingException(
                    "Could not parse value as attribute assignations: \"" + attributeValue + "\"");
        }
       
        final Map<String,String> newAttributeValues = new HashMap<String,String>(assignations.size() + 1, 1.0f);
       
        for (final Assignation assignation : assignations) {
           
            final IStandardExpression leftExpr = assignation.getLeft();
            final Object leftValue = leftExpr.execute(configuration, arguments);

            final IStandardExpression rightExpr = assignation.getRight();
            final Object rightValue = rightExpr.execute(configuration, arguments);

            final String newAttributeName = (leftValue == null? null : leftValue.toString());
            if (StringUtils.isEmptyOrWhitespace(newAttributeName)) {
                throw new TemplateProcessingException(
                        "Attribute name expression evaluated as null or empty: \"" + leftExpr + "\"");
            }

            if (TemplateModeUtils.isHtml(arguments.getTemplateResolution().getTemplateMode()) &&
                    ArrayUtils.contains(Standards.HTML_CONDITIONAL_FIXED_VALUE_ATTR_NAMES, newAttributeName)) {
View Full Code Here

TOP

Related Classes of org.thymeleaf.exceptions.TemplateProcessingException

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.