0

I have problem with enabling expression language to work in tile configuration file. Spring MVC version is 3.2.4 and tiles version is 3.0.3

What did I miss? tiles-config:

<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE tiles-definitions PUBLIC
   "-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN"
   "http://tiles.apache.org/dtds/tiles-config_3_0.dtd">

<tiles-definitions>
   <definition name="base.definition"    preparer="org.apache.tiles.test.preparer.RequestSettingViewPreparer"
    template="/WEB-INF/jsp/layout.jsp">
    <put-attribute name="title" expression="${page-title}" />
    <put-attribute name="header" value="/WEB-INF/jsp/header.jsp" />
    <put-attribute name="menu" value="/WEB-INF/jsp/menu.jsp" />
    <put-attribute name="body" value="" />
    <put-attribute name="footer" value="/WEB-INF/jsp/footer.jsp" />
</definition>

<definition name="contact" extends="base.definition">
    <put-attribute name="body" value="/WEB-INF/jsp/contact.jsp" />
</definition>

</tiles-definitions>

spring configuration:

    <bean id="viewResolver"
    class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass">
    <value>
        org.springframework.web.servlet.view.tiles3.TilesView
    </value>
</property>
</bean>
<bean id="tilesConfigurer"
    class="org.springframework.web.servlet.view.tiles3.TilesConfigurer">

            <property name="definitions" >
                <list>
                    <value>/WEB-INF/tiles-config.xml</value>
                </list>
            </property>
             <property name="checkRefresh" value="true" />
            <property name="useMutableTilesContainer" value="true" />   
</bean>

on layout.jsp I have:

    <title><tiles:insertAttribute name="title" ignore="true"/></title>

and in controller I was trying to set page-title on this ways:

@RequestMapping("/index")
public String listContacts(Map<String, Object> map, HttpServletRequest request) {

    map.put("contact", new Contact());
    map.put("contactList", contactService.listContact());
    map.put("page-title", "Episys");
    request.getSession().setAttribute("page-title", "Episys");
    request.setAttribute("page-title", "Episys");

    return "contact";
}

What did I miss?

Thanks in advance.

Kamil Sobala
  • 53
  • 1
  • 9

1 Answers1

0

According to the documentation you'll need to use a CompleteAutoloadTilesContainerFactory in order for EL to work.

If haven't tested this, but the javadoc of TilesConfigurer seems to indicate that you should use completeAutoLoad. This will register a CompleteAutoloadTilesInitializer(tiles-extras module).

Make sure that you read the documentation of the CompleteAutoloadTilesContainerFactory so that you understand the implications of the the complete-autoload mode.

Pieter
  • 2,745
  • 14
  • 17