You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jonathan M Z <wo...@yahoo.com> on 2005/03/07 19:55:49 UTC

tiles:insert and tiles:put an attribute and the import it to request scope

dear folks,
I know that I can insert an attribute into a  jsp page
by using tiles:insert and tiles put as the following:
 <tiles:insert page="/basic/myLayout.jsp"
flush="true">
            <tiles:put name="param1"  value="My first
page" />
	     <tiles:put name="nav" value="/common/nav.jsp" />

</tiles:insert>
but what if I want to get the value of this attribute
from one of its sub jsp pages(eg. nav.jsp)
I have tried using <tiles:importAttribute
scope="request"/> to import all the tiles attributes
into the request scope.  But it doesn't seem like the
attributes get imported into the request scope
when I print out all the attribute names from the
request as the following in nav.jsp:
 <tiles:importAttribute scope="request"/>
<%
	Enumeration e=request.getAttributeNames();
	while(e.hasMoreElements()){
		out.println(e.nextElement()+ " <>");
	}
 %>
neither was I able to use<bean:write name="param1"/>
in nav.jsp

what's wrong?

thanks




	
		
__________________________________ 
Celebrate Yahoo!'s 10th Birthday! 
Yahoo! Netrospective: 100 Moments of the Web 
http://birthday.yahoo.com/netrospective/

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: tiles:insert and tiles:put an attribute and the import it to request scope

Posted by Tim Christopher <ti...@gmail.com>.
Not sure if this is what you're asking but here's a quick example that
shows how to access the information stored in the tiles-defs.xml in a
file other than your layout page....

# Extract from tiles-defs.xml #
--------------------------------------------
<definition name=".public.welcome" path="/WEB-INF/pages/layout.jsp">
  <put name="title" value="My home page"/>
  <put name="content" value="/WEB-INF/pages/content.jsp"/>
  <put name="somepage" value="/WEB-INF/pages/somepage.jsp"/>
</definition>

# Extract from layout.jsp #
-------------------------------------
<tiles:importAttribute/>
<h1><tiles:getAsString name="title"/></h1>
<tiles:insert attribute="content">
  <tiles:put name="somepage" value="${somepage}"/>
</tiles:insert>

# Extract from content.jsp #
------------------------------------
<tiles:importAttribute name="somepage"/>
<tiles:insert attribute="somepage"/>


Hope that helps,

Tim Christopher



On Mon, 7 Mar 2005 10:55:49 -0800 (PST), Jonathan M Z
<wo...@yahoo.com> wrote:
> dear folks,
> I know that I can insert an attribute into a  jsp page
> by using tiles:insert and tiles put as the following:
> <tiles:insert page="/basic/myLayout.jsp"
> flush="true">
>            <tiles:put name="param1"  value="My first
> page" />
>             <tiles:put name="nav" value="/common/nav.jsp" />
> 
> </tiles:insert>
> but what if I want to get the value of this attribute
> from one of its sub jsp pages(eg. nav.jsp)
> I have tried using <tiles:importAttribute
> scope="request"/> to import all the tiles attributes
> into the request scope.  But it doesn't seem like the
> attributes get imported into the request scope
> when I print out all the attribute names from the
> request as the following in nav.jsp:
> <tiles:importAttribute scope="request"/>
> <%
>        Enumeration e=request.getAttributeNames();
>        while(e.hasMoreElements()){
>                out.println(e.nextElement()+ " <>");
>        }
> %>
> neither was I able to use<bean:write name="param1"/>
> in nav.jsp
> 
> what's wrong?
> 
> thanks
> 
> __________________________________
> Celebrate Yahoo!'s 10th Birthday!
> Yahoo! Netrospective: 100 Moments of the Web
> http://birthday.yahoo.com/netrospective/
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org