6

This one's not very short, so please bear with me.
I'm developing a web app with Spring 3.0, Apache Tiles 2.2 and Spring WebFlow 2.2. One important requirement is that it needs to be very modular, meaning each application module will be delivered as a separate Jar file. This can be done by loading resources and configs through the classpath.
I would like to bundle in this jar file all classes, bean configs, view definitions, flow definitions and jsp pages for the module. The first 2 are trivial.
For the next 2 I found solutions:
flow definitions
base-path can be loaded from classpath

<webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices" base-path="classpath:/org/example/webflow/samples">
    <webflow:flow-location-pattern value="/**/*-flow.xml" />
</webflow:flow-registry>

view definitions
TilesConfigurer can also load through classpath

<bean id="tilesViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    <property name="viewClass" value="org.springframework.web.servlet.view.tiles2.TilesView"/>
</bean>
<bean id="tilesConfigurer" class="org.springframework.web.servlet.view.tiles2.TilesConfigurer">
    <property name="definitions">
        <list>
            <value>classpath:/org/example/**/tiles/tile-views.xml</value>
    </list>
</property>
</bean>

The only thing left is resolving pages, preferably through something like:

<definition name="myPage" extends="main">
    <put-attribute name="header" value="classpath:/org/example/pages/headers/view_events.jsp" />
    <put-attribute name="siteContent" value="classpath:/org/example/pages/admin/view_events.jsp" />
    <put-attribute name="footer" value="classpath:/org/example/pages/blank.jsp" />
</definition>

Is there any way of achieving the desired result? The closest thing I got through search was Apache Tiles wildcard support and EL support, but it's not what I need.
Thanks in advance.

1 Answer 1

2

I've got something very similar as you described. I solved adding "tiles-el" to my pom.xml, then was just matter of switch the "value" to "expression" on my tiles definitions like this

   <definition name="mypage" extends="main">
        <put-attribute name="header" expression="${header}"/>

You can even play with simple condition on the expression like this

<put-attribute name="header" expression="/WEB-INF/layouts/${bean.field ? 'path1/' : 'path2/'}header.jsp">
1
  • expression + tile-el solved my problem too. expressions can be also used in template with templateExpression attribute: <definition name="mydefinition" templateExpression="classpath:/com/test/mytemplate.jsp"> <put-attribute name="title" value="This is a title."/> <put-attribute name="header" value="/header.jsp"/> <put-attribute name="body" expression="classpath:/com/test/mybody.jsp"/> </definition> Aug 6, 2016 at 7:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.