You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tiles.apache.org by "Smith, David W" <da...@bankofamerica.com> on 2009/10/05 15:05:12 UTC

wildcards

Are wildcards allowed in the extends attribute of a tiles definition?
Using tiles 2.1.3 with struts 2.0.14

Started with

      <definition name="sales_rates_application.layout"
extends="general.logon.layout">

            <put-attribute name="title_page_name" value="Sales Rates" />

      </definition>     

            

      <definition name="sales_rates_kickoff.page"
extends="sales_rates_application.layout">

            <put-attribute name="body"
value="/pages/sales_rates/sales_rates_kickoff.jsp" />

      </definition>

            

Added wildcards to the body. This works

 

      <definition name="*_kickoff.page"
extends="sales_rates_application.layout">

            <put-attribute name="body"
value="/pages/{1}/{1}_kickoff.jsp" />

      </definition>

            

Added wildcard to extends. This doesn't work.

 

      <definition name="*_kickoff.page"
extends="{1}_application.layout">

            <put-attribute name="body"
value="/pages/{1}/{1}_kickoff.jsp" />

      </definition>

 

Get error message

 

[10/5/09 9:01:57:051 EDT] 0000002d SystemErr     R
org.apache.tiles.definition.NoSuchDefinitionException: Error while
resolving definition inheritance: child '*_kickoff.page' can't find its
ancestor '{1}_application.layout'. Please check your description file.

[10/5/09 9:01:57:083 EDT] 0000002d SystemErr     R    at
org.apache.tiles.definition.dao.ResolvingLocaleUrlDefinitionDAO.resolveI
nheritance(ResolvingLocaleUrlDefinitionDAO.java:128)

[10/5/09 9:01:57:083 EDT] 0000002d SystemErr     R    at
org.apache.tiles.definition.dao.ResolvingLocaleUrlDefinitionDAO.resolveI
nheritances(ResolvingLocaleUrlDefinitionDAO.java:80)

[10/5/09 9:01:57:083 EDT] 0000002d SystemErr     R    at
org.apache.tiles.definition.dao.ResolvingLocaleUrlDefinitionDAO.postDefi
nitionLoadOperations(ResolvingLocaleUrlDefinitionDAO.java:64)

[10/5/09 9:01:57:083 EDT] 0000002d SystemErr     R    at
org.apache.tiles.definition.dao.CachingLocaleUrlDefinitionDAO.loadDefini
tionsFromURLs(CachingLocaleUrlDefinitionDAO.java:220)

[10/5/09 9:01:57:083 EDT] 0000002d SystemErr     R    at
org.apache.tiles.definition.dao.CachingLocaleUrlDefinitionDAO.loadDefini
tions(CachingLocaleUrlDefinitionDAO.java:207)

[10/5/09 9:01:57:083 EDT] 0000002d SystemErr     R    at
org.apache.tiles.definition.dao.CachingLocaleUrlDefinitionDAO.checkAndlo
adDefinitions(CachingLocaleUrlDefinitionDAO.java:190)

[10/5/09 9:01:57:083 EDT] 0000002d SystemErr     R    at
org.apache.tiles.definition.dao.CachingLocaleUrlDefinitionDAO.getDefinit
ions(CachingLocaleUrlDefinitionDAO.java:153)

[10/5/09 9:01:57:083 EDT] 0000002d SystemErr     R    at
org.apache.tiles.definition.dao.CachingLocaleUrlDefinitionDAO.getDefinit
ion(CachingLocaleUrlDefinitionDAO.java:121)

[10/5/09 9:01:57:083 EDT] 0000002d SystemErr     R    at
org.apache.tiles.definition.dao.CachingLocaleUrlDefinitionDAO.getDefinit
ion(CachingLocaleUrlDefinitionDAO.java:55)

[10/5/09 9:01:57:083 EDT] 0000002d SystemErr     R    at
org.apache.tiles.definition.UrlDefinitionsFactory.getDefinition(UrlDefin
itionsFactory.java:104)

[10/5/09 9:01:57:083 EDT] 0000002d SystemErr     R    at
org.apache.tiles.impl.BasicTilesContainer.getDefinition(BasicTilesContai
ner.java:363)

[10/5/09 9:01:57:083 EDT] 0000002d SystemErr     R    at
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.jav
a:617)

[10/5/09 9:01:57:083 EDT] 0000002d SystemErr     R    at
org.apache.tiles.impl.BasicTilesContainer.render(BasicTilesContainer.jav
a:322)

[10/5/09 9:01:57:083 EDT] 0000002d SystemErr     R    at
org.apache.struts2.views.tiles.TilesResult.doExecute(TilesResult.java:10
4)

[10/5/09 9:01:57:083 EDT] 0000002d SystemErr     R    at
org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSu
pport.java:178)

[10/5/09 9:01:57:083 EDT] 0000002d SystemErr     R    at
com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultAct
ionInvocation.java:348)

[10/5/09 9:01:57:083 EDT] 0000002d SystemErr     R    at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvo
cation.java:253)

[10/5/09 9:01:57:083 EDT] 0000002d SystemErr     R    at
com.bofa.libris.web.interceptors.IbeInterceptor.intercept(IbeInterceptor
.java:45)

[10/5/09 9:01:57:083 EDT] 0000002d SystemErr     R    at
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultAct
ionInvocation.java:224)

[10/5/09 9:01:57:083 EDT] 0000002d SystemErr     R    at
com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultAct
ionInvocation.java:223)

[10/5/09 9:01:57:083 EDT] 0000002d SystemErr     R    at
com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerS
tack.java:455)

[10/5/09 9:01:57:083 EDT] 0000002d SystemErr     R    at
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvo
cation.java:221)

[10/5/09 9:01:57:083 EDT] 0000002d SystemErr     R    at
com.bofa.libris.web.interceptors.AuthenticationInterceptor.intercept(Aut
henticationInterceptor.java:56)

etc.        






Re: wildcards

Posted by Antonio Petrelli <an...@gmail.com>.
2009/10/5 Smith, David W <da...@bankofamerica.com>:
>> Can you open a JIRA issue please? And if you want to submit a patch,
>> you're welcome :-D
>
> Submitted JIRA issue TILES-475. Please let me know if I submitted it
> correctly.

It's ok thank you :-)

Antonio

RE: wildcards

Posted by "Smith, David W" <da...@bankofamerica.com>.
> Can you open a JIRA issue please? And if you want to submit a patch,
> you're welcome :-D

Submitted JIRA issue TILES-475. Please let me know if I submitted it
correctly.

David

Re: wildcards

Posted by Antonio Petrelli <an...@gmail.com>.
2009/10/5 Smith, David W <da...@bankofamerica.com>:
> Yet you can have a wildcard in the template definition. Isn't the parent
> just an extension of the template.

The parent should be considered a half-filled template.
However, I changed my mind. It is difficult to do, but not impossible,
the wildcard-based definitions should be evaluated and resolved only
when requested.
Can you open a JIRA issue please? And if you want to submit a patch,
you're welcome :-D

Ciao
Antonio

RE: wildcards

Posted by "Smith, David W" <da...@bankofamerica.com>.
Yet you can have a wildcard in the template definition. Isn't the parent
just an extension of the template.

Example from the tiles web site.

the wildcard-based style (available by default):

<definition name="test.definition*.message*" template="/layout{1}.jsp">
    <put-attribute name="title"  value="This definition has a message:
{2}."/>
    <put-attribute name="header" value="/header.jsp"/>
    <put-attribute name="body"   value="/body.jsp"/>
</definition>

David

Re: wildcards

Posted by Antonio Petrelli <an...@gmail.com>.
2009/10/5 Smith, David W <da...@bankofamerica.com>:
> Are wildcards allowed in the extends attribute of a tiles definition?

No. This for two reasons.
The first is technical: since, historically, Tiles loads all the
definitions and resolves all inheritance at load time, it's impossible
to do a search for an "unresolved" parent definition. This problem,
however, can be overcome using a non-resolving technique, that is
potentially slower.

The second is about design: does it make sense to have a dynamic
parent definition?

Antonio

Re: wildcards

Posted by Antonio Petrelli <an...@gmail.com>.
Just a note, see inside:

2009/10/5 Smith, David W <da...@bankofamerica.com>:
> Are wildcards allowed in the extends attribute of a tiles definition?
>      <definition name="sales_rates_application.layout"
> extends="general.logon.layout">
>
>            <put-attribute name="title_page_name" value="Sales Rates" />
>
>      </definition>
>
>      <definition name="*_kickoff.page"
> extends="sales_rates_application.layout">
>
>            <put-attribute name="body"
> value="/pages/{1}/{1}_kickoff.jsp" />
>
>      </definition>

The above works, but this not:

      <definition name="*_application.layout"
 extends="general.logon.layout">

            <put-attribute name="title_page_name" value="Sales Rates" />

      </definition>

      <definition name="*_kickoff.page"
 extends="sales_rates_application.layout">

            <put-attribute name="body"
 value="/pages/{1}/{1}_kickoff.jsp" />

      </definition>

This because Tiles tries to resolve a parent definition when loading a
wildcard-based definition, that does not find.

Antonio

RE: Session Attribute in Tiles Definition

Posted by "Smith, David W" <da...@bankofamerica.com>.
Thanks Clayton. Adding a preparer worked.

It seems like Tiles should be able to do this for you so that you don't
have to a create special preparer just to insert a value from the
session or the request into an attribute.

David Smith


RE: Session Attribute in Tiles Definition

Posted by "Rabenda, Clay" <Cl...@mtvnmix.com>.
David,
I'm not sure if there's a way to do exactly what you're asking but I can
suggest another way that I've used.
With a preparer you might do something this:

Put an place-holder string into the tiles configuration like so:

	<put-attribute name="title_page_name" value="Sales
[SALES_RATES_SERVICE_TYPE] Rates" /> </definition>

Wire up a preparer for the definition:

	<definition name="SalesRates_application.layout"
extends="general.logon.layout"
preparer="com.claytonrabenda.awesometitlepreparer">

In the preparer, grab the attribute and replace the string:
	
	String theTitle = (String)
attributeContext.getAttribute("title_page_name").getValue();
      //Do replacement here using session
	attributeContext.putAttribute("title", new Attribute(theTitle));

Hope this helps!
-Clayton Rabenda


-----Original Message-----
From: Smith, David W [mailto:david.w.smith@bankofamerica.com] 
Sent: Tuesday, October 06, 2009 12:12 PM
To: users@tiles.apache.org
Subject: Session Attribute in Tiles Definition

Is it possible to add attributes from the session to the put attribute
of a tiles definition. I would like to do something like...

<definition name="SalesRates_application.layout"
extends="general.logon.layout">
	<put-attribute name="title_page_name" value="Sales
${sessonScope.SALES_RATES_SERVICE_TYPE} Rates" /> </definition>

What do I need to setup to allow the expression language to be able to
parse the session attribute. Can Struts 2 expressions such as
%{#session.SALES_RATES_SERVICE_TYPE} also be used?

The expression language support page on the tiles web site has the
example

<definition name="test.composite.el.definition"
templateExpression="${layout}"
preparer="org.apache.tiles.test.preparer.RequestSettingViewPreparer">
      <put-attribute name="title"  value="This is a configured composite
definition."/>
      <put-attribute name="header" value="/header.jsp"/>
      <put-attribute name="body"   expression="${requestScope.body}"/>
</definition>

Where does the templateExpression= and expression= attributes come from?
I don't see them defined in the tiles reference sheet.

David Smith





RE: Session Attribute in Tiles Definition

Posted by "Smith, David W" <da...@bankofamerica.com>.
Thanks Antonio. Looking forward to Tiles 2.2

David

-----Original Message-----
From: Antonio Petrelli [mailto:antonio.petrelli@gmail.com] 
Sent: Tuesday, October 06, 2009 2:29 PM
To: users@tiles.apache.org
Subject: Re: Session Attribute in Tiles Definition

2009/10/6 Smith, David W <da...@bankofamerica.com>:
> Tiles 2.1.3

Ok, then you should be able to use EL in all Tiles tags.
But in this case remember that expressions are evaluated at "put
time", not at "rendering time".
If you want expression evaluation, you need Tiles 2.2.0 (still in
alpha stage) where you can use:
<tiles:put expression="..." />
where the expression can be EL. Notice that this must be a string!!!
This means that you have to compose a string in a way it does not get
evaluated, such as:
${'$' + '{mybean'}'}
You can also use OGNL or MVEL.

The syntax is the same as the one for the definition files:
http://tiles.apache.org/framework/tutorial/advanced/el-support.html

Ciao
Antonio

Re: Session Attribute in Tiles Definition

Posted by Antonio Petrelli <an...@gmail.com>.
2009/10/6 Smith, David W <da...@bankofamerica.com>:
> Tiles 2.1.3

Ok, then you should be able to use EL in all Tiles tags.
But in this case remember that expressions are evaluated at "put
time", not at "rendering time".
If you want expression evaluation, you need Tiles 2.2.0 (still in
alpha stage) where you can use:
<tiles:put expression="..." />
where the expression can be EL. Notice that this must be a string!!!
This means that you have to compose a string in a way it does not get
evaluated, such as:
${'$' + '{mybean'}'}
You can also use OGNL or MVEL.

The syntax is the same as the one for the definition files:
http://tiles.apache.org/framework/tutorial/advanced/el-support.html

Ciao
Antonio

RE: Session Attribute in Tiles Definition

Posted by "Smith, David W" <da...@bankofamerica.com>.
Tiles 2.1.3

-----Original Message-----
From: Antonio Petrelli [mailto:antonio.petrelli@gmail.com] 
Sent: Tuesday, October 06, 2009 2:02 PM
To: users@tiles.apache.org
Subject: Re: Session Attribute in Tiles Definition

First of all, what version of Tiles are you using? The answer depends on this.

Antonio

2009/10/6 Smith, David W <da...@bankofamerica.com>:
> Is it possible to add attributes from the session to the put attribute
> of a tiles definition. I would like to do something like...
>
> <definition name="SalesRates_application.layout"
> extends="general.logon.layout">
>        <put-attribute name="title_page_name" value="Sales
> ${sessonScope.SALES_RATES_SERVICE_TYPE} Rates" />
> </definition>
>
> What do I need to setup to allow the expression language to be able to
> parse the session attribute. Can Struts 2 expressions such as
> %{#session.SALES_RATES_SERVICE_TYPE} also be used?
>
> The expression language support page on the tiles web site has the
> example
>
> <definition name="test.composite.el.definition"
> templateExpression="${layout}"
> preparer="org.apache.tiles.test.preparer.RequestSettingViewPreparer">
>      <put-attribute name="title"  value="This is a configured composite
> definition."/>
>      <put-attribute name="header" value="/header.jsp"/>
>      <put-attribute name="body"   expression="${requestScope.body}"/>
> </definition>
>
> Where does the templateExpression= and expression= attributes come from?
> I don't see them defined in the tiles reference sheet.
>
> David Smith
>
>
>
>
>

Re: Session Attribute in Tiles Definition

Posted by Antonio Petrelli <an...@gmail.com>.
First of all, what version of Tiles are you using? The answer depends on this.

Antonio

2009/10/6 Smith, David W <da...@bankofamerica.com>:
> Is it possible to add attributes from the session to the put attribute
> of a tiles definition. I would like to do something like...
>
> <definition name="SalesRates_application.layout"
> extends="general.logon.layout">
>        <put-attribute name="title_page_name" value="Sales
> ${sessonScope.SALES_RATES_SERVICE_TYPE} Rates" />
> </definition>
>
> What do I need to setup to allow the expression language to be able to
> parse the session attribute. Can Struts 2 expressions such as
> %{#session.SALES_RATES_SERVICE_TYPE} also be used?
>
> The expression language support page on the tiles web site has the
> example
>
> <definition name="test.composite.el.definition"
> templateExpression="${layout}"
> preparer="org.apache.tiles.test.preparer.RequestSettingViewPreparer">
>      <put-attribute name="title"  value="This is a configured composite
> definition."/>
>      <put-attribute name="header" value="/header.jsp"/>
>      <put-attribute name="body"   expression="${requestScope.body}"/>
> </definition>
>
> Where does the templateExpression= and expression= attributes come from?
> I don't see them defined in the tiles reference sheet.
>
> David Smith
>
>
>
>
>

Session Attribute in Tiles Definition

Posted by "Smith, David W" <da...@bankofamerica.com>.
Is it possible to add attributes from the session to the put attribute
of a tiles definition. I would like to do something like...

<definition name="SalesRates_application.layout"
extends="general.logon.layout">
	<put-attribute name="title_page_name" value="Sales
${sessonScope.SALES_RATES_SERVICE_TYPE} Rates" />
</definition>

What do I need to setup to allow the expression language to be able to
parse the session attribute. Can Struts 2 expressions such as
%{#session.SALES_RATES_SERVICE_TYPE} also be used?

The expression language support page on the tiles web site has the
example

<definition name="test.composite.el.definition"
templateExpression="${layout}"
preparer="org.apache.tiles.test.preparer.RequestSettingViewPreparer">
      <put-attribute name="title"  value="This is a configured composite
definition."/>
      <put-attribute name="header" value="/header.jsp"/>
      <put-attribute name="body"   expression="${requestScope.body}"/>
</definition>

Where does the templateExpression= and expression= attributes come from?
I don't see them defined in the tiles reference sheet.

David Smith