Tiles 2 + Spring

47 views
Skip to first unread message

Dave Snowdon

unread,
Mar 5, 2009, 12:02:53 PM3/5/09
to jav...@googlegroups.com
Hi folks

I'm going to be starting on a new project soon based on Spring MVC. We have a requirement to be able to compose output from multiple components so we are planning to use Tiles 2.

Although Spring supports Tiles 2 the documentation is a little sketchy and I wondered if anyone on the list had used Spring MVC & Tiles2 together and had any advice to share.

Also, Is anyone aware of a web-based user interface for managing Tiles2 configuration? Another requirement we have is for a web based management interface that would allow us to view & edit Tiles2 templates  - I haven't found anything yet but if anyone here knows anything please shout before I spend some time rolling my own.

thanks!

Dave

Adam Hardy

unread,
Mar 5, 2009, 12:12:10 PM3/5/09
to jav...@googlegroups.com
Hi Dave,

I used Spring MVC and Tiles1. AFAI recall, it was just a case of
configuring the spring-tiles driver in the dependency injection
container. A case of set-it-and-forget-it.

The names of the tiles are what you output as your MVC view value in
Spring, and setting up the tiles to use inheritance has its quirks, but
their mailing list is excellent. One of the committers Antonio generally
answers questions really quickly.

Unless tomcat or whatever has improved since then though you do need to
restart the webapp to see your changes when you modify tiles.xml.

I didn't use a GUI, I just hacked the XML. If you're that allergic to
XML, the Eclipse XML editor probably helps.

Regards
Adam

Joe Walnes

unread,
Mar 5, 2009, 12:24:18 PM3/5/09
to jav...@googlegroups.com
On Thu, Mar 5, 2009 at 5:02 PM, Dave Snowdon <dave.s...@gmail.com> wrote:
Hi folks

Howdy Dave
 
I'm going to be starting on a new project soon based on Spring MVC. We have a requirement to be able to compose output from multiple components so we are planning to use Tiles 2.

Although Spring supports Tiles 2 the documentation is a little sketchy and I wondered if anyone on the list had used Spring MVC & Tiles2 together and had any advice to share.

I haven't done it, but I know that Tiles 2 is not coupled to any particular MVC framework, so there should be no problems there. In your config files, you just need to point to the Spring MVC paths instead of the direct JSPs.

Also, Is anyone aware of a web-based user interface for managing Tiles2 configuration? Another requirement we have is for a web based management interface that would allow us to view & edit Tiles2 templates  - I haven't found anything yet but if anyone here knows anything please shout before I spend some time rolling my own.

An approach you could try is to use a standard HTML WYSIWYG component, and add some macros to support the Tiles definitions, and have these dynamically served (e.g. from a database). However, this is not easily possible using JSP, but you can plug in your own view technologies to support this. In fact Tiles comes with FreeMarker support - though if you're allowing users to change these templates you'll have to lock them down to prevent them from doing malicious or stupid things that could take down your server.

Sorry, but I can't resist hawking my warez - please also spend just a few mins evaluating SiteMesh - you may like it :).

-Joe

Dave Snowdon

unread,
Mar 5, 2009, 3:23:13 PM3/5/09
to jav...@googlegroups.com
Hi Joe

2009/3/5 Joe Walnes <joe.w...@gmail.com>


I haven't done it, but I know that Tiles 2 is not coupled to any particular MVC framework, so there should be no problems there. In your config files, you just need to point to the Spring MVC paths instead of the direct JSPs.

If I understand correctly , your saying  we can use Tiles to compose the output from multiple Spring controllers without having to use ViewPreparers (ie use spring controllers for everything). That would be great if it works.

We have written a demo app that uses view preparers to insert dynamic content into the pages generated by tiles - managing the interaction between view preparers and spring controllers seems a little awkward though and I was wondering if there is a better way.


Sorry, but I can't resist hawking my warez - please also spend just a few mins evaluating SiteMesh - you may like it :).

I did use SiteMesh a couple of years ago on a different project -  I thought then that SiteMesh was for decorating the output from a single servlet rather than for combining page fragments from multiple sources. I'll have to give SiteMesh another look.

cheers

Dave
 


-Joe




Dave Snowdon

unread,
Mar 5, 2009, 3:57:02 PM3/5/09
to jav...@googlegroups.com
Hi Adam

We might have to do some hacking then to see if we can modify a live Tiles configuration.

We have managed to write a demo app that uses Tiles view preparers to insert dynamic content, but the integration with Spring isn't (at least in the app we've written so far) quite as good as I'd hoped. We'd hoped for something more like composing the output from multiple spring controllers and the view preparers sort of give you that but not quite as conveniently as I'd hoped. It may be that we've just not found the right approach yet though.

It's not so much that we're allergic to XML - it's just that the infrastructure we're replacing had the ability for live sites to be modified (structurally as well as just content) using a web-based interface as we have to provide equivalent functionality.

cheers

Dave

2009/3/5 Adam Hardy <adam....@cyberspaceroad.com>

Adam Hardy

unread,
Mar 6, 2009, 5:23:49 AM3/6/09
to jav...@googlegroups.com
Dave,
what you're doing doesn't sound like a run-of-the-mill project so I
would expect that you'd face challenges with whichever framework you
used. Basically though I can't visualize what you're trying to do -
multiple controllers for one request seems to be a contradiction. Good
luck though. Sounds like fun.

Adam




Dave Snowdon on 05/03/09 20:57, wrote:
> Hi Adam
>
> We might have to do some hacking then to see if we can modify a live
> Tiles configuration.
>
> We have managed to write a demo app that uses Tiles view preparers to
> insert dynamic content, but the integration with Spring isn't (at
> least in the app we've written so far) quite as good as I'd hoped.
> We'd hoped for something more like composing the output from multiple
> spring controllers and the view preparers sort of give you that but
> not quite as conveniently as I'd hoped. It may be that we've just not
> found the right approach yet though.
>
> It's not so much that we're allergic to XML - it's just that the
> infrastructure we're replacing had the ability for live sites to be
> modified (structurally as well as just content) using a web-based
> interface as we have to provide equivalent functionality.
>
> cheers
>
> Dave
>
> 2009/3/5 Adam Hardy <adam....@cyberspaceroad.com
> <mailto:adam....@cyberspaceroad.com>>

Dave Snowdon

unread,
Mar 6, 2009, 6:26:29 AM3/6/09
to jav...@googlegroups.com
Adam,
Yeah, I'm not doing a great job of explaining things.

I take your point about multiple controllers - to a large extent we're limited by what the existing architecture can do in that we have to reproduce much of the existing functionality even if it's not frequently used.

Maybe there's enough interesting stuff in this project to justify doing a presentation once we've got things working.

cheers

Dave

2009/3/6 Adam Hardy <adam....@cyberspaceroad.com>
Reply all
Reply to author
Forward
0 new messages