You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tiles.apache.org by stanlick <st...@gmail.com> on 2008/11/09 01:29:57 UTC

Struts 2 and Tiles 2.1.0

I would like to use EL in tiles definitions.  Is it supported by Struts 2.x
and is there a recipe for this?  I downloaded Tiles 2.1.0 and reviewed the
changes, but the web.xml has undergone radical change and I thought I'd do a
little fact finding before performing open heart surgery on my working
application.

Peace,
Scott
-- 
View this message in context: http://www.nabble.com/Struts-2-and-Tiles-2.1.0-tp20402071p20402071.html
Sent from the tiles users mailing list archive at Nabble.com.


Re: Struts 2 and Tiles 2.1.0

Posted by stanlick <st...@gmail.com>.
Thanks Adam -- 

I looked at this option, but would rather use EL in tiles definitions.  It
would be a much cleaner (and intuitive) solution.

Scott



Adam Hardy (debian) wrote:
> 
> stanlick on 09/11/08 00:29, wrote:
>> I would like to use EL in tiles definitions.  Is it supported by Struts
>> 2.x
>> and is there a recipe for this?  I downloaded Tiles 2.1.0 and reviewed
>> the
>> changes, but the web.xml has undergone radical change and I thought I'd
>> do a
>> little fact finding before performing open heart surgery on my working
>> application.
> 
> Hi Scott,
> not directly in tiles.xml, however with just one more step, it's easy.
> This is 
> the approach I took.
> 
> Tiles.xml definition:
> 
>    <definition name="collatedAnalysisInsert.tile"
>      extends="collatedAnalysisList.tile">
>      <put-attribute name="tilesSubmitAction" value="collated-analysis/new"
> />
>      <put-attribute name="bodyContentTile"
>        value="/WEB-INF/jsp/collated-analysis/edit.jsp" />
>      <put-attribute name="tilesContextHeader"
>        value="collatedanalysis.insert.pageHeader" />
>      <put-attribute name="tilesAdditionalTitle" type="string"
>        value="collatedRun.portfolio.title" />
>    </definition>
> 
> Sorry it's a bit of dry example. The last attribute 'tilesAdditionalTitle'
> is 
> actually the reference to a javabean object with nested objects found in
> the 
> requestAttributes, but as far as tiles is concerned, it's just a string
> attribute.
> 
> In the JSP, I can retrieve it from the requestAttributes using the JSTL 
> requestScope[] map. I use it like this:
> 
> <tiles:importAttribute />
> <h1 class="contextHeader">
>    <fmt:message key="${tilesContextHeader}">
>      <c:if test="${!empty tilesAdditionalTitle}">
>        <fmt:param value="${requestScope[tilesAdditionalTitle]}"  />
>      </c:if>
>    </fmt:message>
> </h1>
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/Struts-2-and-Tiles-2.1.0-tp20402071p20419250.html
Sent from the tiles users mailing list archive at Nabble.com.


Re: Struts 2 and Tiles 2.1.0

Posted by Adam Hardy <ah...@cyberspaceroad.com>.
stanlick on 09/11/08 00:29, wrote:
> I would like to use EL in tiles definitions.  Is it supported by Struts 2.x
> and is there a recipe for this?  I downloaded Tiles 2.1.0 and reviewed the
> changes, but the web.xml has undergone radical change and I thought I'd do a
> little fact finding before performing open heart surgery on my working
> application.

Hi Scott,
not directly in tiles.xml, however with just one more step, it's easy. This is 
the approach I took.

Tiles.xml definition:

   <definition name="collatedAnalysisInsert.tile"
     extends="collatedAnalysisList.tile">
     <put-attribute name="tilesSubmitAction" value="collated-analysis/new" />
     <put-attribute name="bodyContentTile"
       value="/WEB-INF/jsp/collated-analysis/edit.jsp" />
     <put-attribute name="tilesContextHeader"
       value="collatedanalysis.insert.pageHeader" />
     <put-attribute name="tilesAdditionalTitle" type="string"
       value="collatedRun.portfolio.title" />
   </definition>

Sorry it's a bit of dry example. The last attribute 'tilesAdditionalTitle' is 
actually the reference to a javabean object with nested objects found in the 
requestAttributes, but as far as tiles is concerned, it's just a string attribute.

In the JSP, I can retrieve it from the requestAttributes using the JSTL 
requestScope[] map. I use it like this:

<tiles:importAttribute />
<h1 class="contextHeader">
   <fmt:message key="${tilesContextHeader}">
     <c:if test="${!empty tilesAdditionalTitle}">
       <fmt:param value="${requestScope[tilesAdditionalTitle]}"  />
     </c:if>
   </fmt:message>
</h1>


Re: Struts 2 and Tiles 2.1.0

Posted by Antonio <an...@gmail.com>.
2008/11/14 stanlick <st...@gmail.com>:
> It could easily be either one at this point!  Rather than just complain
> about the docs, I'd like to offer corrective criticism and volunteer to tidy
> them up myself once this is resolved.

Fantastic! But then why don't you write to Tiles Developers list?
http://tiles.apache.org/mail-lists.html

Thanks
Antonio

Re: Struts 2 and Tiles 2.1.0

Posted by stanlick <st...@gmail.com>.
Thanks bro -- 

It could easily be either one at this point!  Rather than just complain
about the docs, I'd like to offer corrective criticism and volunteer to tidy
them up myself once this is resolved.  I think the localePatternPaths was
empty, but will verify when I get to St. Louis today.

Peace,
Scott



Antonio Petrelli-3 wrote:
> 
> 2008/11/13 stanlick <st...@gmail.com>:
>>
>> Antonio --
>>
>> Should I expect the ResolvingLocaleUrlDefinitionDAO to perform a wildcard
>> def name lookup?
> 
> Yes.
> 
>>  Although my wildcard definition *is* in the definitions
>> Map, resolveWildcardDefinition() is not being executed because
>> localePatternPaths.containsKey(customizationKey) ==false
>>
>>            if (retValue == null
>>                    && localePatternPaths.containsKey(customizationKey)) {
>>                retValue = resolveWildcardDefinition(localePatternPaths
>>                        .get(customizationKey), name);
> 
> This might be the problem. Can you see ifthe localePatternPaths map is
> filled or not?
> Because if it is filled then it is a problem of evaluation, otherwise
> a problem of initialization.
> 
> Antonio
> 
> 

-- 
View this message in context: http://www.nabble.com/Struts-2-and-Tiles-2.1.0-tp20402071p20499570.html
Sent from the tiles users mailing list archive at Nabble.com.


Re: Struts 2 and Tiles 2.1.0

Posted by Antonio <an...@gmail.com>.
2008/11/13 stanlick <st...@gmail.com>:
>
> Antonio --
>
> Should I expect the ResolvingLocaleUrlDefinitionDAO to perform a wildcard
> def name lookup?

Yes.

>  Although my wildcard definition *is* in the definitions
> Map, resolveWildcardDefinition() is not being executed because
> localePatternPaths.containsKey(customizationKey) ==false
>
>            if (retValue == null
>                    && localePatternPaths.containsKey(customizationKey)) {
>                retValue = resolveWildcardDefinition(localePatternPaths
>                        .get(customizationKey), name);

This might be the problem. Can you see ifthe localePatternPaths map is
filled or not?
Because if it is filled then it is a problem of evaluation, otherwise
a problem of initialization.

Antonio

Re: Struts 2 and Tiles 2.1.0

Posted by stanlick <st...@gmail.com>.
Antonio -- 

Should I expect the ResolvingLocaleUrlDefinitionDAO to perform a wildcard
def name lookup?  Although my wildcard definition *is* in the definitions
Map, resolveWildcardDefinition() is not being executed because
localePatternPaths.containsKey(customizationKey) ==false

            if (retValue == null
                    && localePatternPaths.containsKey(customizationKey)) {
                retValue = resolveWildcardDefinition(localePatternPaths
                        .get(customizationKey), name);

Scott
-- 
View this message in context: http://www.nabble.com/Struts-2-and-Tiles-2.1.0-tp20402071p20487804.html
Sent from the tiles users mailing list archive at Nabble.com.


Re: Struts 2 and Tiles 2.1.0

Posted by stanlick <st...@gmail.com>.
That's cool bro -- 

I'll pick it apart and let you know what I find out.  I'm not sure who
injected all these new features, but they rock!

Peace,
Scott



Antonio Petrelli-3 wrote:
> 
> 2008/11/12 stanlick <st...@gmail.com>:
>>
>> Doh!  I mean this definition:
>>
>>        <definition name="layout.*.*" extends="myapp.homePage">
>>                <put-attribute name="content" value="/tiles/{1}.jsp" />
>>                <put-attribute name="title" value="{2}" />
>>        </definition>
> 
> I simply don't know, it might be a bug. For this reason I asked you to
> try without Struts, to see if it is a Struts Tiles plugin bug or a
> Tiles bug.
> 
> Antonio
> 
> 

-- 
View this message in context: http://www.nabble.com/Struts-2-and-Tiles-2.1.0-tp20402071p20481631.html
Sent from the tiles users mailing list archive at Nabble.com.


Re: Struts 2 and Tiles 2.1.0

Posted by Antonio <an...@gmail.com>.
2008/11/12 stanlick <st...@gmail.com>:
>
> Doh!  I mean this definition:
>
>        <definition name="layout.*.*" extends="myapp.homePage">
>                <put-attribute name="content" value="/tiles/{1}.jsp" />
>                <put-attribute name="title" value="{2}" />
>        </definition>

I simply don't know, it might be a bug. For this reason I asked you to
try without Struts, to see if it is a Struts Tiles plugin bug or a
Tiles bug.

Antonio

Re: Struts 2 and Tiles 2.1.0

Posted by stanlick <st...@gmail.com>.
Doh!  I mean this definition:

	<definition name="layout.*.*" extends="myapp.homePage">
		<put-attribute name="content" value="/tiles/{1}.jsp" />
		<put-attribute name="title" value="{2}" />
	</definition>





stanlick wrote:
> 
> Thanks A -- 
> 
> If I have this tiles definition
> 
> 		<action name="layout.*.*">
> 			<result>layout.{1}.{2}</result>
> 		</action>
> 
> why is this definition request not found?
> 
> Unable to find the definition 'layout.core.Really_Weird_Title'
> 
> 

-- 
View this message in context: http://www.nabble.com/Struts-2-and-Tiles-2.1.0-tp20402071p20465262.html
Sent from the tiles users mailing list archive at Nabble.com.


Re: Struts 2 and Tiles 2.1.0

Posted by stanlick <st...@gmail.com>.
Thanks A -- 

If I have this tiles definition

		<action name="layout.*.*">
			<result>layout.{1}.{2}</result>
		</action>

why is this definition request not found?

Unable to find the definition 'layout.core.Really_Weird_Title'

-- 
View this message in context: http://www.nabble.com/Struts-2-and-Tiles-2.1.0-tp20402071p20464710.html
Sent from the tiles users mailing list archive at Nabble.com.


Re: Struts 2 and Tiles 2.1.0

Posted by Antonio <an...@gmail.com>.
2008/11/12 stanlick <st...@gmail.com>:
> Does Tiles/2 strip the URL and construct a "realtime" definition from a
> request or do you have to get involved in the life-cycle processing?

It is Struts 2 that strips the URL. In your case, Tiles is called only
when the definition:
myapp.tile{1}.titleFred Title
is called. The substitution of {1} is done by Struts 2 (because it is
a Struts result). But the matching with the wildcard-based definition
is done by Tiles.
The definition is created at runtime once if it is not present (it
will be reused if it has been already created).

>  I read
> another article where you had suggested a view preparer???

Probably it was for Tiles 2.0, can you link it?

>  I guess I'm a
> little unclear on what the framework is doing with these substitutions.

First Struts 2 matches the URL and substitutes in the result.
Then Tiles 2 is called, matches the definition and substitute the
placeholders in attributes and template.

> If you can clear it up for me and additional code needs to be written, I'd
> be happy to work on modifying the S2 plug-in.

Just as a reminder, for questions about the development of Struts
contact the Struts developers mailing list:
http://struts.apache.org/mail.html

Thanks
Antonio

Re: Struts 2 and Tiles 2.1.0

Posted by stanlick <st...@gmail.com>.
Thanks brother -- 

I could not tell if this was the case or if I had things wired up wrong.  I
added the optional jars as per the Tiles/2 setup and nearly have the EL
working with the existing Struts 2.1 Tiles plugin.  I was a little confused
about  "If you insert a definition that matches the definition, for
example:" in this doc

http://tiles.apache.org/framework/tutorial/advanced/wildcard.html

Does Tiles/2 strip the URL and construct a "realtime" definition from a
request or do you have to get involved in the life-cycle processing?  I read
another article where you had suggested a view preparer???  I guess I'm a
little unclear on what the framework is doing with these substitutions.

If you can clear it up for me and additional code needs to be written, I'd
be happy to work on modifying the S2 plug-in.

Peace,
Scott


Antonio Petrelli-3 wrote:
> 
> 2008/11/12 Antonio <an...@gmail.com>:
>> Probably Struts 2 is not configured correctly, because the
>> Struts2/Tiles2 plugin does not work with Tiles 2.1. I think that
> 
> Sorry I forgot to complete the sentense :-D
> I think that Struts2/Tiles2 plugin does not create/assign the wildcard
> matcher, or some dependency is not resolved at all.
> Try using Tiles 2.1 alone.
> 
> Antonio
> 
> 

-- 
View this message in context: http://www.nabble.com/Struts-2-and-Tiles-2.1.0-tp20402071p20459949.html
Sent from the tiles users mailing list archive at Nabble.com.


Re: Struts 2 and Tiles 2.1.0

Posted by Antonio <an...@gmail.com>.
2008/11/12 Antonio <an...@gmail.com>:
> Probably Struts 2 is not configured correctly, because the
> Struts2/Tiles2 plugin does not work with Tiles 2.1. I think that

Sorry I forgot to complete the sentense :-D
I think that Struts2/Tiles2 plugin does not create/assign the wildcard
matcher, or some dependency is not resolved at all.
Try using Tiles 2.1 alone.

Antonio

Re: Struts 2 and Tiles 2.1.0

Posted by Antonio <an...@gmail.com>.
2008/11/11 stanlick <st...@gmail.com>:
> 12:03:09,587  WARN org.apache.tiles.impl.BasicTilesContainer.render():392 -
> Unable to find the definition 'myapp.tilecore.titleFred Title'
>
> My tiles definition is as follows:
>
>        <definition name="myapp.tile*.title*" extends="myapp.homePage">
>                <put-attribute name="content" value="{1}"/>
>                <put-attribute name="title"     value="{2}"/>
>        </definition>
>
> And here is the Struts action mapping:
>
>                <action name="tile-*">
>                        <result>myapp.tile{1}.titleFred Title</result>
>                </action>

Probably Struts 2 is not configured correctly, because the
Struts2/Tiles2 plugin does not work with Tiles 2.1. I think that
Did you try using Tiles 2.1 alone?

Antonio

Re: Struts 2 and Tiles 2.1.0

Posted by stanlick <st...@gmail.com>.
Okay, I nearly have things wired together!  I read, stitched and read some
more and sort of have things working.  However, when I attempt to leverage a
wildcard definition, I receive the following message:

12:03:09,571 DEBUG org.apache.tiles.impl.BasicTilesContainer.render():384 -
Render request recieved for definition 'myapp.tilecore.titleFred Title'
12:03:09,587  WARN org.apache.tiles.impl.BasicTilesContainer.render():392 -
Unable to find the definition 'myapp.tilecore.titleFred Title'

My tiles definition is as follows:

	<definition name="myapp.tile*.title*" extends="myapp.homePage">
		<put-attribute name="content" value="{1}"/>
		<put-attribute name="title"	value="{2}"/>
	</definition>

And here is the Struts action mapping:

		<action name="tile-*">
			<result>myapp.tile{1}.titleFred Title</result>
		</action>


Any idea what might be going on?

Peace,
Scott
-- 
View this message in context: http://www.nabble.com/Struts-2-and-Tiles-2.1.0-tp20402071p20447073.html
Sent from the tiles users mailing list archive at Nabble.com.


Re: Struts 2 and Tiles 2.1.0

Posted by stanlick <st...@gmail.com>.
Actually, S2 wraps the request object and translates EL syntax into OGNL
stack.find.  

P.S. Tiles 2.1 looks wicked cool!

Scott



Antonio Petrelli-3 wrote:
> 
> 2008/11/9 stanlick <st...@gmail.com>:
>>
>> I would like to use EL in tiles definitions.  Is it supported by Struts
>> 2.x
>> and is there a recipe for this?
> 
> Wait a minute: Struts 2 does not support EL in its JSP tags, but Tiles
> 2.1 supports EL both in JSP tags (also for Tiles 2.0) and in Tiles
> definitions:
> http://tiles.apache.org/framework/tutorial/advanced/el-support.html
> 
> Ciao
> Antonio
> 
> 

-- 
View this message in context: http://www.nabble.com/Struts-2-and-Tiles-2.1.0-tp20402071p20419221.html
Sent from the tiles users mailing list archive at Nabble.com.


Re: Struts 2 and Tiles 2.1.0

Posted by Antonio <an...@gmail.com>.
2008/11/9 stanlick <st...@gmail.com>:
>
> I would like to use EL in tiles definitions.  Is it supported by Struts 2.x
> and is there a recipe for this?

Wait a minute: Struts 2 does not support EL in its JSP tags, but Tiles
2.1 supports EL both in JSP tags (also for Tiles 2.0) and in Tiles
definitions:
http://tiles.apache.org/framework/tutorial/advanced/el-support.html

Ciao
Antonio