tiles-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stevo Slavić <ssla...@gmail.com>
Subject Re: Extending generic tiles 2 template
Date Tue, 08 Mar 2011 19:31:10 GMT
Now I have:

	<definition name="foo/bar" extends="standard" preparer="fooBarViewPreparer">
		<put-attribute name="pageTitle" type="string" value="foo.bar.title"
cascade="true"/>
		<put-attribute name="content" value="/WEB-INF/jsp/foo/bar.jsp" />
	</definition>

	<definition name="*/*" extends="standard">
		<put-attribute name="pageTitle" type="string" value="{1}.{2}.title"
cascade="true"/>
		<put-attribute name="content" value="/WEB-INF/jsp/{1}/{2}.jsp" />
	</definition>

Just because foo/bar has a view preparer I have to repeat all the rest
- this is not DRY. Then I tried with

	<definition name="foo/bar" extends="foo/bar/withViewPreparere"
preparer="fooBarViewPreparer"/>

	<definition name="*/*/withViewPreparer" extends="standard">
		<put-attribute name="pageTitle" type="string" value="{1}.{2}.title"
cascade="true"/>
		<put-attribute name="content" value="/WEB-INF/jsp/{1}/{2}.jsp" />
	</definition>

	<definition name="*/*" extends="standard">
		<put-attribute name="pageTitle" type="string" value="{1}.{2}.title"
cascade="true"/>
		<put-attribute name="content" value="/WEB-INF/jsp/{1}/{2}.jsp" />
	</definition>

Some code duplication but it didn't work anyway (same reason as for
next). Then I tried with

	<definition name="foo/bar" extends="generic/foo/bar"
preparer="fooBarViewPreparer"/>

	<definition name="generic/*/*" extends="standard">
		<put-attribute name="pageTitle" type="string" value="{1}.{2}.title"
cascade="true"/>
		<put-attribute name="content" value="/WEB-INF/jsp/{1}/{2}.jsp" />
	</definition>

	<definition name="*/*" extends="generic/{1}/{2}"/>


and that didn't work either - getting following exception:


org.apache.tiles.definition.NoSuchDefinitionException: Error while
resolving definition inheritance: child 'foo/bar' can't find its
ancestor 'generic/foo/bar'. Please check your description file.
	at org.apache.tiles.definition.dao.ResolvingLocaleUrlDefinitionDAO.resolveInheritance(ResolvingLocaleUrlDefinitionDAO.java:153)
	at org.apache.tiles.definition.dao.ResolvingLocaleUrlDefinitionDAO.resolveInheritances(ResolvingLocaleUrlDefinitionDAO.java:105)
	at org.apache.tiles.definition.dao.ResolvingLocaleUrlDefinitionDAO.loadDefinitionsFromURLs(ResolvingLocaleUrlDefinitionDAO.java:67)
	at org.apache.tiles.definition.dao.ResolvingLocaleUrlDefinitionDAO.loadParentDefinitions(ResolvingLocaleUrlDefinitionDAO.java:58)
	at org.apache.tiles.definition.dao.CachingLocaleUrlDefinitionDAO.loadDefinitionsFromURLs(CachingLocaleUrlDefinitionDAO.java:239)
	at org.apache.tiles.definition.dao.ResolvingLocaleUrlDefinitionDAO.loadDefinitionsFromURLs(ResolvingLocaleUrlDefinitionDAO.java:65)
	at org.apache.tiles.definition.dao.CachingLocaleUrlDefinitionDAO.loadDefinitions(CachingLocaleUrlDefinitionDAO.java:222)
	at org.apache.tiles.definition.dao.CachingLocaleUrlDefinitionDAO.checkAndloadDefinitions(CachingLocaleUrlDefinitionDAO.java:204)
	at org.apache.tiles.definition.dao.CachingLocaleUrlDefinitionDAO.getDefinitions(CachingLocaleUrlDefinitionDAO.java:154)
	at org.apache.tiles.definition.dao.CachingLocaleUrlDefinitionDAO.getDefinition(CachingLocaleUrlDefinitionDAO.java:123)
	at org.apache.tiles.definition.dao.CachingLocaleUrlDefinitionDAO.getDefinition(CachingLocaleUrlDefinitionDAO.java:54)
	at org.apache.tiles.definition.UnresolvingLocaleDefinitionsFactory.getDefinition(UnresolvingLocaleDefinitionsFactory.java:105)
	at org.springframework.web.servlet.view.tiles2.TilesView.checkResource(TilesView.java:92)
	at org.springframework.web.servlet.view.UrlBasedViewResolver.loadView(UrlBasedViewResolver.java:421)
	at org.springframework.web.servlet.view.AbstractCachingViewResolver.createView(AbstractCachingViewResolver.java:158)
	at org.springframework.web.servlet.view.UrlBasedViewResolver.createView(UrlBasedViewResolver.java:384)
	at org.springframework.web.servlet.view.AbstractCachingViewResolver.resolveViewName(AbstractCachingViewResolver.java:77)
	at org.springframework.web.servlet.DispatcherServlet.resolveViewName(DispatcherServlet.java:1078)
	at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1027)
	at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817)
	at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
	at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:644)
	at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:549)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)


ResolvingLocaleUrlDefinitionDAO in resolveInheritance called for
"foo/bar" definition sets "foo/bar" as visited to avoid endless
recursion, and then tries to get definition for "generic/foo/bar" and
it doesn't find one - it tries to get it from a map where definitions
are keyed by definition name, and there is no definition with name/key
"generic/foo/bar", but there is one with name/key "generic/*/*".

So, it seems extends attribute of a tile definition can neither
reference tile name wildcards with placeholders nor in case of fixed
(without placeholders) extends attribute value it can not be a
reference to a matching tile with wildcards in name. It seems not same
mechanism is used when one gets a tile from tiles and when tiles
resolves inheritance. If same mechanism was used previous two examples
would work; I guess to avoid encless recursion in that case tile
definitions would have to be keyed on tile definition instance hash
value and not definition name.

Did anyone configure regexp pattern matching with Apache Tiles 2 and
Spring 3?  http://tiles.apache.org/framework/tutorial/advanced/wildcard.html#Using_different_pattern_matching_languages
Not sure if it's available by default. I doubt it would help me solve this one.

Regards,
Stevo.

On Tue, Mar 8, 2011 at 4:55 PM, Antonio Petrelli
<antonio.petrelli@gmail.com> wrote:
> 2011/3/8 Antonio Petrelli <antonio.petrelli@gmail.com>:
>> 2011/3/8 Stevo Slavić <sslavic@gmail.com>:
>>> I understand, but how can one express that a tile definition extends
>>> one with wildcards in name?
>>
>> IIRC you can use placeholders in "extends" attribute.
>
> I rephrase it, sorry.
> If your definition is wildcard-ed and you want to express "extends"
> attribute in a parametrical way, you can use placeholders.
> OTOH if you want to extend a definition that is defined with
> wildcards, simply express *explicitly* a definition that will be
> intercepted by the wildcards.
> You can combine both things.
>
> Antonio
>

Mime
View raw message