Package org.thymeleaf.exceptions

Examples of org.thymeleaf.exceptions.TemplateProcessingException


            } else if (NONE_INLINE.equals(attributeValue.toLowerCase())) {
                return null;
            }
        }
       
        throw new TemplateProcessingException(
                "Cannot recognize value for \"" + attributeName + "\". Allowed values are " +
                "\"" + TEXT_INLINE + "\", \"" + JAVASCRIPT_INLINE + "\", " +
                "\"" + DART_INLINE + "\" and \"" + NONE_INLINE + "\"");
       
    }
View Full Code Here


        }
        if (VALUE_BODY.equalsIgnoreCase(resultStr)) {
            return RemovalType.BODY;
        }

        throw new TemplateProcessingException(
                "Invalid value specified for \"" + attributeName + "\": only 'all', 'tag', 'body', 'none' " +
                "and 'all-but-first' are allowed, but \"" + attributeValue + "\" was specified.");

    }
View Full Code Here

    @Override
    protected boolean isVisible(final Arguments arguments, final Element element, final String attributeName) {
       
        if (!arguments.hasLocalVariable(AbstractStandardSwitchStructureAttrProcessor.SWITCH_VARIABLE_NAME)) {
            throw new TemplateProcessingException(
                    "Cannot specify a \"" + attributeName + "\" attribute in an environment where no " +
                    "switch operator has been defined before.");
        }
       
        final SwitchStructure switchStructure =
View Full Code Here

            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 OR EQUAL TO from Expression \"" +
                        expression.getStringRepresentation() + "\". Left is \"" +
                        leftValue + "\", right is \"" + rightValue + "\"");
            }
        }
View Full Code Here

        }
       
        final Expression expression = Expression.parse(preprocessedInput.trim());
       
        if (expression == null) {
            throw new TemplateProcessingException("Could not parse as expression: \"" + input + "\"");
        }
       
        if (configuration != null) {
            ExpressionCache.putExpressionIntoCache(configuration, preprocessedInput, expression);
        }
View Full Code Here

        final ExpressionSequence expressionSequence =
                internalParseExpressionSequence(preprocessedInput.trim());

        if (expressionSequence == null) {
            throw new TemplateProcessingException("Could not parse as expression sequence: \"" + input + "\"");
        }

        if (configuration != null) {
            ExpressionCache.putExpressionSequenceIntoCache(configuration, preprocessedInput, expressionSequence);
        }
View Full Code Here

        }

        String linkBase = (String) base;
       
        if (!isWebContext(processingContext.getContext()) && !isLinkBaseAbsolute(linkBase) && !isLinkBaseServerRelative(linkBase)) {
            throw new TemplateProcessingException(
                    "Link base \"" + linkBase + "\" cannot be context relative (/) or page relative unless you implement the " +
                    IWebContext.class.getName() + " interface (context is of class: " +
                    processingContext.getContext().getClass().getName() + ")");
        }
       
View Full Code Here

            // We know parameterNameExpr cannot be null (the Assignation class would not allow it)
            final Object parameterNameValue = parameterNameExpr.execute(configuration, processingContext, expContext);
            final String parameterName = (parameterNameValue == null? null : parameterNameValue.toString());

            if (StringUtils.isEmptyOrWhitespace(parameterName)) {
                throw new TemplateProcessingException(
                        "Parameters in link expression \"" + expression.getStringRepresentation() + "\" are " +
                        "incorrect: parameter name expression \"" + parameterNameExpr.getStringRepresentation() +
                        "\" evaluated as null or empty string.");
            }
View Full Code Here

        if (logger.isTraceEnabled()) {
            logger.trace("[THYMELEAF][{}] Evaluating message: \"{}\"", TemplateEngine.threadIndex(), expression.getStringRepresentation());
        }

        if (!(processingContext instanceof Arguments)) {
            throw new TemplateProcessingException(
                    "Cannot evaluate expression \"" + expression + "\". Message externalization expressions " +
                    "can only be evaluated in a template-processing environment (as a part of an in-template expression) " +
                    "where evaluation context is an " + Arguments.class.getClass() + " instance instead of an instance of " +
                    processingContext.getClass().getName());
        }
       
        final Arguments arguments = (Arguments) processingContext;

        final IStandardExpression baseExpression = expression.getBase();
        Object messageKey = baseExpression.execute(configuration, arguments, expContext);
        messageKey = LiteralValue.unwrap(messageKey);
        if (messageKey != null && !(messageKey instanceof String)) {
            messageKey = messageKey.toString();
        }
        if (StringUtils.isEmptyOrWhitespace((String)messageKey)) {
            throw new TemplateProcessingException(
                    "Message key for message resolution must be a non-null and non-empty String");
        }
       

        final Object[] messageParameters =
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 LESS OR EQUAL TO 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 LESS OR EQUAL TO from Expression \"" +
                        expression.getStringRepresentation() + "\". Left is \"" +
                        leftValue + "\", right is \"" + rightValue + "\"");
            }
        }
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.