Coder Social home page Coder Social logo

thymeleaf-extras-tiles2's Introduction

thymeleaf-extras-tiles2's People

Contributors

danielfernandez avatar ultraq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

thymeleaf-extras-tiles2's Issues

NullPointerException on null model in ThymeleafTilesView

I'm using spring mvc and when there is no model for the view NullPointerException is thrown.

Relevant stack trace:
java.lang.NullPointerException
org.thymeleaf.extras.tiles2.spring.web.view.ThymeleafTilesView.exposeModelAsRequestAttributes(ThymeleafTilesView.java:176)
org.thymeleaf.extras.tiles2.spring.web.view.ThymeleafTilesView.render(ThymeleafTilesView.java:130)
org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1180)
org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:950)
org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:852)
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:882)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:778)

I looked at the code and i think that line 130:
exposeModelAsRequestAttributes(model, request);
should be:
exposeModelAsRequestAttributes(mergedModel, request);

SpringMVC+thymeleaf+Tiles config

Hello,

I´m facing some beginner problem setting up the configuration of SpringMVC+Tiles+Thymeleaf:

my spring.xml is:

<bean id="tilesConfigurer" class="org.thymeleaf.extras.tiles2.spring.web.configurer.ThymeleafTilesConfigurer">
  <property name="definitions">
    <list>
      <value>/WEB-INF/tiles-defs.xml</value>
    </list>
  </property>
</bean>

<bean id="templateResolver"
    class="org.thymeleaf.templateresolver.ServletContextTemplateResolver">
    <property name="prefix" value="/WEB-INF/templates/" />
    <property name="suffix" value=".html" />
    <property name="templateMode" value="XHTML" />
</bean>

<bean id="templateEngine" class="org.thymeleaf.spring3.SpringTemplateEngine">
    <property name="templateResolver" ref="templateResolver" />
    <property name="additionalDialects">
        <set>
            <bean class="org.thymeleaf.extras.tiles2.dialect.TilesDialect"/>
        </set>
    </property>
</bean>

<bean id="tilesViewResolver" class="org.thymeleaf.spring3.view.ThymeleafViewResolver">
    <property name="templateEngine" ref="templateEngine" />
    <property name="viewClass" value="org.thymeleaf.extras.tiles2.spring.web.view.ThymeleafTilesView"/>
    <property name="viewNames" value="*.html, *.xhtml, *.xml" />
    <property name="order" value="1"/>
</bean>

and I'm supposing tiles-defs.xml is correctly configured, as web.xml, and so on.
So regarding to that info, is there any mistake I made? Because I don't see any relation between some beans...

Thanks!

Migration to tiles 3

Would it be hard to migrate the support for Tiles 3? It seems Spring 3.2 now supports Tiles 3 so I was wondering if Thymeleaf could support Tiles 3 as well.

Tiles +Thymeleaf integration problem

Hi,
I am new to the Thymeleafe, facing problem in tiles configuratiion and usage without Spring, can you please provide web.xml configuration. how to include tiles-def in web.xml or can you provide some sample example end to end how to configure in servlet and in web.xml

How to use ViewPreparer?

I tested sample ViewPreparer. but doesn't work.

@Component("testPreparer")
public class TestPreparer implements ViewPreparer {

    @Override
    public void execute(TilesRequestContext tilesContext, AttributeContext attributeContext) {
          attributeContext.putAttribute("message", new Attribute("hello world"));
    }
}

in definition:

<definition name="signin" template="signin" preparer="testPreparer" />

signin.html

...
<div th:text="${message}">prototype message</div>
...

ThymeleafTilesView to expose Thymeleaf's own evaluation context as a model variable in order to support ConversionService

Hi Daniel,

First of all, thank you so much for this great project. I'm evaluating this project in order to make the right recommendation to our management on the technologies for use in the View layer.

Please bare with me if there is missing information as this is my first post.

Evaluation Stack:

  • Thymeleaf 2.1.2.RELEASE
  • Thymeleaf Extras Tiles2 Integration 2.1.0.RELEASE
  • Spring Framework 3.2.6.RELEASE

The new syntax, double braces "{{", to invoke the ConversionService introduced in Thymeleaf 2.1.2 does not work. After tracing the bug, it turns out the ThymeleafTilesView needs to expose thymeleafEvaluationContext as a model variable that is similar to the one in ThymeleafView. I have tried to fix the bug by adding the following code after line 165 of ThymeleafTilesView and it works.

final ApplicationContext applicationContext = getApplicationContext();
// 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);

Let me know how could I help to add this fix to the next release of this project. Thank you.

tiles:insertDefinition

As a Tiles user I've been happy to find this integration library, but now I am puzzled if it fits in my usage of Tiles layouting. I am using tiles like this:

tiles.xml contains only layout definition

<tiles-definitions>
    <definition name="tiles-authenticated" template="/WEB-INF/layout/tiles-authenticated.jsp">
        <put-attribute name="title" value="Default Authenticated Title" />
        <put-attribute name="header" value="/WEB-INF/layout/header.jsp" />
        <put-attribute name="footer" value="/WEB-INF/layout/footer.jsp" />
        <put-attribute name="menu" value="/WEB-INF/layout/menu.jsp" />
        <put-attribute name="body" value="/WEB-INF/layout/body.jsp" />
    </definition>
</tiles-definitions>

tiles-authenticated.jsp sets the layout

<%@ page pageEncoding="UTF-8" contentType="text/html;charset=UTF-8"%>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title><tiles:getAsString name="title"/></title>
  </head>
  <body>
        <table>
      <tr>
        <td colspan="2">
          <tiles:insertAttribute name="header" />
        </td>
      </tr>
      <tr>
        <td>
          <tiles:insertAttribute name="menu" />
        </td>
        <td>
          <tiles:insertAttribute name="body" />
        </td>
      </tr>
      <tr>
        <td colspan="2">
          <tiles:insertAttribute name="footer" />
        </td>
      </tr>
    </table>
  </body>
</html>

And any html page defines only title and body part

<%@ page pageEncoding="UTF-8" contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/jsp/taglibs.jsp" %>
<tiles:insertDefinition name="tiles-authenticated">
<tiles:putAttribute name="title" value="User Page"/>
<tiles:putAttribute name="body">

<h1>User Page</h1>
....
<a href="<c:url value='/ui/user'/>">My Detail</a>
....
<a href="<c:url value='/ui/entity/list'/>">Entity List</a>
....
</tiles:putAttribute>
</tiles:insertDefinition>

Is it possible to do this in thymeleaf-extras-tiles2 ? I did not find support for tiles:insertDefinition which is crucial to this use case

Thanks,
Martin

Try to avoid the possible creation of new sessions

Both AbstractTilesFragmentHandlingAttrProcessor and TilesStringAttrProcessor include calls like:

final ServletContext servletContext = request.getSession().getServletContext();

In Servlet API < 3.0, there is no other way to obtain the ServletContext object, but at least we should try to "carry" that object somehow from a place where it is accessible so that we don't need to create sessions for executing those processors.

ThymeleafTilesView is not of type ThymeleafView

I am using spring configuration with latest beta2 SNAPSHOT and i get this exception:

Caused by: java.lang.IllegalArgumentException: Given view class [org.thymeleaf.extras.tiles2.spring.web.view.ThymeleafTilesView] is not of type [org.thymeleaf.spring3.view.ThymeleafView]
at org.thymeleaf.spring3.view.ThymeleafViewResolver.setViewClass(ThymeleafViewResolver.java:133)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.springframework.beans.BeanWrapperImpl.setPropertyValue(BeanWrapperImpl.java:1154)
... 34 more

I am not shure if this is a problem in thymeleaf-extras-tiles2 or thymeleaf-spring3.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.