Package org.thymeleaf.spring3.processor.attr

Examples of org.thymeleaf.spring3.processor.attr.AbstractSpringFieldAttrProcessor


    return resolver;
  }

  @Bean
  public SpringTemplateEngine templateEngine() {
    SpringTemplateEngine engine = new SpringTemplateEngine();
    engine.setTemplateResolver(templateResolver());
    return engine;
  }
View Full Code Here


        final ThymeleafEvaluationContext evaluationContext =
                new ThymeleafEvaluationContext(applicationContext, conversionService);
        mergedModel.put(ThymeleafEvaluationContext.THYMELEAF_EVALUATION_CONTEXT_CONTEXT_VARIABLE_NAME, evaluationContext);

       
        final SpringWebContext context =
                new SpringWebContext(request, response, servletContext, getLocale(), mergedModel, getApplicationContext());


        final String templateName;
        final IFragmentSpec nameFragmentSpec;
        if (!viewTemplateName.contains("::")) {
            // No fragment specified at the template name

            templateName = viewTemplateName;
            nameFragmentSpec = null;

        } else {
            // Template name contains a fragment name, so we should parse it as such

            final Configuration configuration = viewTemplateEngine.getConfiguration();
            final ProcessingContext processingContext = new ProcessingContext(context);

            final String dialectPrefix = getStandardDialectPrefix(configuration);

            final StandardFragment fragment =
                    StandardFragmentProcessor.computeStandardFragmentSpec(
                            configuration, processingContext, viewTemplateName, dialectPrefix, StandardFragmentAttrProcessor.ATTR_NAME);

            if (fragment == null) {
                throw new IllegalArgumentException("Invalid template name specification: '" + viewTemplateName + "'");
            }

            templateName = fragment.getTemplateName();
            nameFragmentSpec = fragment.getFragmentSpec();
            final Map<String,Object> nameFragmentParameters = fragment.getParameters();

            if (nameFragmentParameters != null) {

                if (FragmentSelectionUtils.parameterNamesAreSynthetic(nameFragmentParameters.keySet())) {
                    // We cannot allow synthetic parameters because there is no way to specify them at the template
                    // engine execution!
                    throw new IllegalArgumentException(
                            "Parameters in a view specification must be named (non-synthetic): '" + viewTemplateName + "'");
                }

                context.setVariables(nameFragmentParameters);

            }


        }
View Full Code Here

            final ServletContext servletContext,
            final ApplicationContext applicationContext,
            final ConversionService conversionService) {
        // Create delegating SpringWebContext
        final Locale locale = RequestContextUtils.getLocale(request);
        springWebContext = new SpringWebContext(
            request, response, servletContext, locale, new HashMap(), applicationContext);
        // Perform initializations
        initialize(conversionService);
    }
View Full Code Here

    String fragment = this.process(path, getSpringWebContext(request, response, Locale.UK, model));
    return fragment;
  }

  private IWebContext getSpringWebContext(final HttpServletRequest request, final HttpServletResponse response, final Locale locale, final Map<String,?> model) {
    return new SpringWebContext(request, response, servletContext, locale, model, applicationContext);

  }
View Full Code Here

        vars.put(SpringContextVariableNames.SPRING_REQUEST_CONTEXT, requestContext);

        // copy all spring model attributes into the spring web context as variables
        vars.putAll(RenderContext.get().getModel());

        final IWebContext context = new SpringWebContext(request, response, servletContext, MgnlContext.getWebContext()
                .getRequest().getLocale(), vars, getApplicationContext());

        try (AppendableWriter out = renderingCtx.getAppendable()) {
            // need to ensure engine initialised before getting configuration
            if (!engine.isInitialized()) {
View Full Code Here


    public Map<String,Object> computeExpressionObjectsFromExpressionEvaluator(
            final Arguments arguments, final IStandardVariableExpressionEvaluator expressionEvaluator) {

        final SpelVariableExpressionEvaluator spelExprEval =
                ((expressionEvaluator != null && expressionEvaluator instanceof SpelVariableExpressionEvaluator)?
                        (SpelVariableExpressionEvaluator) expressionEvaluator :
                        SpelVariableExpressionEvaluator.INSTANCE);
        return  spelExprEval.computeExpressionObjects(arguments.getConfiguration(), arguments);

    }
View Full Code Here

   
   
    public SpringStandardDialect() {
        super();
        super.setVariableExpressionEvaluator(SpelVariableExpressionEvaluator.INSTANCE);
        super.setConversionService(new SpringStandardConversionService());
    }
View Full Code Here


        // Expose Thymeleaf's own evaluation context as a model variable
        final ConversionService conversionService =
                (ConversionService) request.getAttribute(ConversionService.class.getName()); // might be null!
        final ThymeleafEvaluationContext evaluationContext =
                new ThymeleafEvaluationContext(applicationContext, conversionService);
        mergedModel.put(ThymeleafEvaluationContext.THYMELEAF_EVALUATION_CONTEXT_CONTEXT_VARIABLE_NAME, evaluationContext);

       
        final SpringWebContext context =
                new SpringWebContext(request, response, servletContext, getLocale(), mergedModel, getApplicationContext());
View Full Code Here

            springWebContext.getHttpServletRequest(), springWebContext.getHttpServletResponse(), springWebContext.getServletContext(), springWebContext.getVariables());
        springWebContext.setVariable(SPRING_REQUEST_CONTEXT, requestContext);
    }

    private void createEvaluationContext(final ConversionService conversionService) {
        ThymeleafEvaluationContext evaluationContext = new ThymeleafEvaluationContext(springWebContext.getApplicationContext(), conversionService);
        evaluationContext.setTypeLocator(new WhitelistTypeLocator());
        springWebContext.setVariable(THYMELEAF_EVALUATION_CONTEXT_CONTEXT_VARIABLE_NAME, evaluationContext);
    }
View Full Code Here



    public EvaluationContext wrapEvaluationContext(
            final EvaluationContext evaluationContext, final Map<String,Object> contextVariables) {
        return new ThymeleafEvaluationContextWrapper(evaluationContext, contextVariables);
    }
View Full Code Here

TOP

Related Classes of org.thymeleaf.spring3.processor.attr.AbstractSpringFieldAttrProcessor

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.