tiles-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lukasz Lenart <lukaszlen...@apache.org>
Subject Re: Using Tiles 3 in Struts 2
Date Thu, 14 Jan 2016 07:07:19 GMT
2016-01-14 4:27 GMT+01:00 Nicolas Le Bas <mail@nlebas.net>:
> Hi Łukasz,
>
> Thanks for taking the time to ask here. It's interesting to see what kind of
> challenges people are facing with tiles, and not so many people share theses
> days.

Thanks for taking time and answering! :)

> Concerning ApplicationResources:
>
> First of all I want to clarify that creating an ApplicationResource object
> does not actually load the file, it merely locates it for later use. Only by
> calling the methods on ApplicationResource later can you proceed with
> reading the file.
>
> - #getResource(path) and #getResources(path) are used for non localized
> resources. Tiles uses them to inventory the tiles.xml files at startup, like
> here:
> https://github.com/apache/tiles/blob/TILES_3_0_X/tiles-core/src/main/java/org/apache/tiles/factory/BasicTilesContainerFactory.java#L220
> or here:
> https://github.com/apache/tiles/blob/TILES_3_0_X/tiles-extras/src/main/java/org/apache/tiles/extras/complete/CompleteAutoloadTilesContainerFactory.java#L203

Those methods return ApplicationResource, how should I construct it?
Right now I'm doing it like this for all tiles*.xml definition files,
should I distinct them based on a suffix ("en", "pl")?

https://github.com/apache/struts/pull/73/files#diff-a4ef02a35b4a5838b0cc73fa5e6236f9R113

> To be honest, I can see you're using it in your StrutsTilesContainerFactory
> (below), and I don't really understand why you're subclassing
> ServletApplicationContext.
>
> https://github.com/apache/struts/pull/73/files#diff-f6b3e4ef563a4a13a4d051eb2e26c379R159

Because I want to have wildcard support without using Tiles wildcard
servlet which is based on Spring

https://github.com/apache/struts/pull/73/files#diff-a4ef02a35b4a5838b0cc73fa5e6236f9R45

> - #getResource(resource, locale) is used to find a localized version of a
> previously located resource. Of course the locale can only be identified at
> request time. There's a cache for performance, but only at request time can
> you know if you need to read /WEB-INF/tiles_en.xml or /WEB-INF/tiles_pl.xml,
> or default to /WEB-INF/tiles.xml. Tiles will read only the files that are
> needed.
>
> I can see you've disabled this feature in your subclass of
> ServletApplicationContext. I can only assume you do not want it.

Disabled? I'd call it a dirt fix ;-) Anyway I see your point, but
right now I have no idea how should I implement that method. I think
it depends on inventory methods above.

> To access HttpServletRequest:
>
> Assuming that struts will always run in a servlet enviroment, I suggest you
> use ServletUtil.getServletRequest(request).getRequest(). There should be an
> equivalent for portlet, but I have to admit our test suite is lacking when
> it comes to portlets.
>
> https://github.com/apache/tiles-request/blob/TREQ_1_0_X/tiles-request-servlet/src/main/java/org/apache/tiles/request/servlet/ServletUtil.java#L90
>
> This will unwrap anything that sits around the ServletRequest object,
> whether it is a JspRequest, FreemarkerRequest, VelocityRequest or whatever
> else. Your current code would only support JSP as a templating engine.

Great, thanks!


Regards
-- 
Łukasz
+ 48 606 323 122 http://www.lenart.org.pl/

Mime
View raw message