thymeleaf / thymeleaf-extras-tiles2 Goto Github PK
View Code? Open in Web Editor NEWThymeleaf integration with Apache Tiles 2.x
Home Page: http://www.thymeleaf.org
Thymeleaf integration with Apache Tiles 2.x
Home Page: http://www.thymeleaf.org
thymeleaf --------- In order to learn more and download the latest version: http://www.thymeleaf.org
Adapt the tiles:fragment
and include
, etc. inclusion mechanism to the modifications applied in thymeleaf/thymeleaf#205.
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);
The following expression for content attribute doesnt work.
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!
Hi,
I opened this post on the thymeleaf forum:
http://forum.thymeleaf.org/Getting-Tiles-put-list-attribute-to-work-with-a-Thymeleaf-template-td4026233.html
I've also had a look at the source code and it seems what I am describing in the forum post is not yet possible with Thymeleaf.
I would be nice to have. What do you think Daniel?
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.
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
I have several definitions which building the with preparer, jsp-fragments and hook them together. At the ende I insert them into the layout definition with an tiles:insertDefinition tag.
Spring Framework's latest SNAPSHOT has removed Tiles 2 support (which has been deprecated for some time). It would be great to get support for Tiles 3.
See http://forum.thymeleaf.org/Thymeleaf-Tiles-I18N-td4025224.html
By allowing the execution of Standard Expressions inside Tiles definitions for type="string" attributes, we could achieve things like easy i18n of attribute texts.
It would be really cool if you use tiles:ignore in conjunction with tiles:substituteby.
http://tiles.apache.org/framework/tiles-jsp/tlddoc/tiles/insertAttribute.html
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>
...
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:
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.
Current implementation of ThymeleafTilesView
is hard-linked to the thymeleaf-spring3
implementation of SpringWebContext
, therefore not being valid for use with the Spring 4 integration module.
In thymeleaf-spring3 support for @PathVariable was added with release 2.0.16.
(thymeleaf/thymeleaf-spring#12)
Please add this to org.thymeleaf.extras.tiles2.spring.web.view.ThymeleafTilesView as well.
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
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.
My command window stays at GPG Passphrase: *
Thymeleaf core added th:replace
(see thymeleaf/thymeleaf#69 ), which should be mirrored at the Tiles integration module.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.