You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Frank Maritato <fr...@overture.com> on 2003/10/02 19:39:42 UTC
tiles and parameters
Hi all, I'm having a problem passing a parameter down from a tiles
definition to a jsp. I can access the value easily in the layout
definition, but I can't get access to it in a file (or action) I'm
inserting into the layout. Here is an example of what I'm doing (cut
down a bit)
tiles.xml:
<definition name="mp.main" path="/tiles/layout/headerContentFooter.jsp">
<put name="nav_key" value="mp" type="string"/>
<put name="content" value="/showcontent.do" />
</definition>
headerContentFooter.jsp:
<tiles:useAttribute name="nav_key" />
<p>nav_key = <%=nav_key%><p>
<tiles:insert attribute="content" />
samplecontent.jsp:
<bean:define id="nav_key" name="nav_key" />
<b>nav_key::: <%=nav_key%></b>
So I'm getting an error in samplecontent.jsp that there is no such
variable in any scope. How can I get it? I can print out the value fine
in the headerContentFooter layout. I also tried adding a
<tiles:useAttribute> in samplecontent.jsp to try and get access to the
variable but that didn't work either. Any help would be appreciated.
Thanks!
--
Frank Maritato
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: tiles and parameters
Posted by Manish Singla <Ma...@Sun.COM>.
You are getting error because "nav_key" is in page context.
thus you cannot retrieve value in included page...
YOu may use <tiles:useAttribute name="nav_key" scope="request" />
in headercontentfooter.jsp
Frank Maritato wrote:
> Hi all, I'm having a problem passing a parameter down from a tiles
> definition to a jsp. I can access the value easily in the layout
> definition, but I can't get access to it in a file (or action) I'm
> inserting into the layout. Here is an example of what I'm doing (cut
> down a bit)
>
> tiles.xml:
> <definition name="mp.main" path="/tiles/layout/headerContentFooter.jsp">
> <put name="nav_key" value="mp" type="string"/>
> <put name="content" value="/showcontent.do" />
> </definition>
>
> headerContentFooter.jsp:
> <tiles:useAttribute name="nav_key" />
> <p>nav_key = <%=nav_key%><p>
> <tiles:insert attribute="content" />
>
> samplecontent.jsp:
> <bean:define id="nav_key" name="nav_key" />
> <b>nav_key::: <%=nav_key%></b>
>
> So I'm getting an error in samplecontent.jsp that there is no such
> variable in any scope. How can I get it? I can print out the value fine
> in the headerContentFooter layout. I also tried adding a
> <tiles:useAttribute> in samplecontent.jsp to try and get access to the
> variable but that didn't work either. Any help would be appreciated.
>
> Thanks!
--
Thanks
Manish Singla
x73166
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: tiles and parameters
Posted by Frank Maritato <fr...@overture.com>.
That didn't work. First I got a ClassCastException because its actually
of type org.apache.struts.tiles.DirectStringAttribute and not
java.lang.string. Even after I adjusted for that, however, I still was
not able to see nav_key or local_nav_key in samplecontent.jsp.
That tiles reference was very helpful though. It said that all
attributes are defined in the "tiles" scope only and are not visible to
sub-tiles. That gave me the idea to redefine the variable into the
request scope. So this is what I did:
in headerContentFooter.jsp:
<bean:define id="nav_key" name="nav_key" toScope="request" />
then in samplecontent.jsp:
<bean:define name="nav_key" scope="request" ignore="true"/>
and that works. Thanks!
Christopher C Worley wrote:
> Frank,
>
> Try this in headerContentFooter.jsp
>
> <tiles:useAttribute id="local_nav_key" name="nav_key"
> classname="java.lang.String" ignore="true" />
> <p>nav_key = <%=local_nav_key%></p>
>
> Here is a good reference for tiles
>
> http://www.lifl.fr/~dumoulin/tiles/tilesAdvancedFeatures.pdf
>
>
>
> -chris worley
>
>> Hi all, I'm having a problem passing a parameter down from a tiles
>> definition to a jsp. I can access the value easily in the layout
>> definition, but I can't get access to it in a file (or action) I'm
>> inserting into the layout. Here is an example of what I'm doing (cut
>> down a bit)
>>
>> tiles.xml:
>> <definition name="mp.main" path="/tiles/layout/headerContentFooter.jsp">
>> <put name="nav_key" value="mp" type="string"/>
>> <put name="content" value="/showcontent.do" />
>> </definition>
>>
>> headerContentFooter.jsp:
>> <tiles:useAttribute name="nav_key" />
>> <p>nav_key = <%=nav_key%><p>
>> <tiles:insert attribute="content" />
>>
>> samplecontent.jsp:
>> <bean:define id="nav_key" name="nav_key" />
>> <b>nav_key::: <%=nav_key%></b>
>>
>> So I'm getting an error in samplecontent.jsp that there is no such
>> variable in any scope. How can I get it? I can print out the value
>> fine in the headerContentFooter layout. I also tried adding a
>> <tiles:useAttribute> in samplecontent.jsp to try and get access to the
>> variable but that didn't work either. Any help would be appreciated.
>>
>> Thanks!
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
--
Frank Maritato
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: tiles and parameters
Posted by Christopher C Worley <cw...@ensystex.com>.
Frank,
Try this in headerContentFooter.jsp
<tiles:useAttribute id="local_nav_key" name="nav_key"
classname="java.lang.String" ignore="true" />
<p>nav_key = <%=local_nav_key%></p>
Here is a good reference for tiles
http://www.lifl.fr/~dumoulin/tiles/tilesAdvancedFeatures.pdf
-chris worley
> Hi all, I'm having a problem passing a parameter down from a tiles
> definition to a jsp. I can access the value easily in the layout
> definition, but I can't get access to it in a file (or action) I'm
> inserting into the layout. Here is an example of what I'm doing (cut
> down a bit)
>
> tiles.xml:
> <definition name="mp.main" path="/tiles/layout/headerContentFooter.jsp">
> <put name="nav_key" value="mp" type="string"/>
> <put name="content" value="/showcontent.do" />
> </definition>
>
> headerContentFooter.jsp:
> <tiles:useAttribute name="nav_key" />
> <p>nav_key = <%=nav_key%><p>
> <tiles:insert attribute="content" />
>
> samplecontent.jsp:
> <bean:define id="nav_key" name="nav_key" />
> <b>nav_key::: <%=nav_key%></b>
>
> So I'm getting an error in samplecontent.jsp that there is no such
> variable in any scope. How can I get it? I can print out the value
> fine in the headerContentFooter layout. I also tried adding a
> <tiles:useAttribute> in samplecontent.jsp to try and get access to the
> variable but that didn't work either. Any help would be appreciated.
>
> Thanks!
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org