You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Sonam Belbase <So...@morganstanley.com> on 2003/10/07 21:39:40 UTC
using an attribute inside a tile
Hi,
I have a layout contentFrameLayout.jsp:
<html>
<head></head>
<body>
<tiles:useAttribute name="screenName" scope="request"/>
<tiles:insert attribute="header" />
<tiles:insert attribute="body" />
<tiles:insert attribute="footer" />
</body>
</html>
In my tiles-def.xml, I assign values to these attributes:
<definition name="content.default" page="/jsp/layouts/contentFrameLayout.jsp">
<put name="screenName" value="Introduction" />
<put name="header" value="/jsp/common/header.jsp" />
<put name="body" value="/jsp/common/introduction.jsp" />
<put name="footer" value="/jsp/common/footer.jsp" />
</definition>
<definition name="signin.default" extends="content.default">
<put name="screenName" value="Sign In" />
<put name="body" value="/jsp/common/signin.jsp" />
</definition>
In struts-config, my action forwards to the definition "content.default" on success.
I am trying to use the attribute screenName inside header.jsp
(which is a tile for contentFrameLayout.jsp) in the following manner:
<TD WIDTH=300 BGCOLOR=#336699 CLASS=bodytextboldwhite>
<! -- value of screenName displayed here -->
<bean:write name="screenName" />
</TD>
I followed some guidelines in the following article:
http://www.developer.com/java/ent/article.php/10933_2192411_5
but the bean:write writes nothing to the screen (i.e the column comes up empty).
It looks like there might be a context problem since doing a bean:write in
the layout jsp works but not in the tile header.jsp. There are no error messages
at runtime.
Does anyone know how I can accomplish this? My main goal is to use the same
layout for every content page and have the option of dynamically displaying the screenName
each time the tile header.jsp is used.
Thanks,
SB
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: using an attribute inside a tile
Posted by Sonam Belbase <So...@morganstanley.com>.
Frank,
I tried this and the bean:write in header.jsp still does not write anything to the screen:
tiles-def.xml:
<definition name="content.default" page="/jsp/layouts/contentFrameLayout.jsp">
<put name="header" value="/jsp/common/header.jsp" />
<put name="screenName" value="Introduction" />
</definition>
contentFrameLayout.jsp:
<tiles:useAttribute name="screenName" />
<bean:define id="label" name="screenName" toScope="request" />
<tiles:insert attribute="begin" />
header.jsp:
<bean:define name="label" scope="request" ignore="true"/>
<bean:write name="label" />
I also tried
header.jsp:
<bean:define name="label" scope="request" ignore="true"/>
<%=label%>
but this results in the error: /ms/user/s/sonam/libra/aeui/0.2/src/ServletExec
Data/default/aeui/pagecompile/_jsp/_common/_beginContent_xjsp.java:43: Undefined variable: label
out.print( String.valueOf( label ) );
Don't know what I am doing wrong..
-Sonam
Frank Maritato wrote:
> I just recently posted a question about this very problem. Attributes
> defined in tiles definitions are available only in the "tiles" scope.
> Therefore, you must redefine the attribute into the request scope if you
> want it available to your sub tiles.
>
> So, in contentFrameLayout.jsp you add the line:
> <bean:define id="screenName" name="screenName" toScope="request" />
>
> And it should work for you.
>
> Sonam Belbase wrote:
> > Hi,
> >
> > I have a layout contentFrameLayout.jsp:
> >
> > <html>
> > <head></head>
> > <body>
> > <tiles:useAttribute name="screenName" scope="request"/>
> > <tiles:insert attribute="header" />
> > <tiles:insert attribute="body" />
> > <tiles:insert attribute="footer" />
> > </body>
> > </html>
> >
> > In my tiles-def.xml, I assign values to these attributes:
> >
> > <definition name="content.default" page="/jsp/layouts/contentFrameLayout.jsp">
> > <put name="screenName" value="Introduction" />
> > <put name="header" value="/jsp/common/header.jsp" />
> > <put name="body" value="/jsp/common/introduction.jsp" />
> > <put name="footer" value="/jsp/common/footer.jsp" />
> > </definition>
> >
> > <definition name="signin.default" extends="content.default">
> > <put name="screenName" value="Sign In" />
> > <put name="body" value="/jsp/common/signin.jsp" />
> > </definition>
> >
> > In struts-config, my action forwards to the definition "content.default" on success.
> >
> > I am trying to use the attribute screenName inside header.jsp
> > (which is a tile for contentFrameLayout.jsp) in the following manner:
> >
> > <TD WIDTH=300 BGCOLOR=#336699 CLASS=bodytextboldwhite>
> > <! -- value of screenName displayed here -->
> > <bean:write name="screenName" />
> > </TD>
> >
> > I followed some guidelines in the following article:
> >
> > http://www.developer.com/java/ent/article.php/10933_2192411_5
> >
> > but the bean:write writes nothing to the screen (i.e the column comes up empty).
> > It looks like there might be a context problem since doing a bean:write in
> > the layout jsp works but not in the tile header.jsp. There are no error messages
> > at runtime.
> >
> > Does anyone know how I can accomplish this? My main goal is to use the same
> > layout for every content page and have the option of dynamically displaying the screenName
> > each time the tile header.jsp is used.
> >
> > Thanks,
> > SB
> >
> >
> > ---------------------------------------------------------------------
> > 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
--
NOTICE: If received in error, please destroy and notify sender. Sender does not waive
confidentiality or privilege, and use is prohibited.
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: using an attribute inside a tile
Posted by Frank Maritato <fr...@overture.com>.
I just recently posted a question about this very problem. Attributes
defined in tiles definitions are available only in the "tiles" scope.
Therefore, you must redefine the attribute into the request scope if you
want it available to your sub tiles.
So, in contentFrameLayout.jsp you add the line:
<bean:define id="screenName" name="screenName" toScope="request" />
And it should work for you.
Sonam Belbase wrote:
> Hi,
>
> I have a layout contentFrameLayout.jsp:
>
> <html>
> <head></head>
> <body>
> <tiles:useAttribute name="screenName" scope="request"/>
> <tiles:insert attribute="header" />
> <tiles:insert attribute="body" />
> <tiles:insert attribute="footer" />
> </body>
> </html>
>
> In my tiles-def.xml, I assign values to these attributes:
>
> <definition name="content.default" page="/jsp/layouts/contentFrameLayout.jsp">
> <put name="screenName" value="Introduction" />
> <put name="header" value="/jsp/common/header.jsp" />
> <put name="body" value="/jsp/common/introduction.jsp" />
> <put name="footer" value="/jsp/common/footer.jsp" />
> </definition>
>
> <definition name="signin.default" extends="content.default">
> <put name="screenName" value="Sign In" />
> <put name="body" value="/jsp/common/signin.jsp" />
> </definition>
>
> In struts-config, my action forwards to the definition "content.default" on success.
>
> I am trying to use the attribute screenName inside header.jsp
> (which is a tile for contentFrameLayout.jsp) in the following manner:
>
> <TD WIDTH=300 BGCOLOR=#336699 CLASS=bodytextboldwhite>
> <! -- value of screenName displayed here -->
> <bean:write name="screenName" />
> </TD>
>
> I followed some guidelines in the following article:
>
> http://www.developer.com/java/ent/article.php/10933_2192411_5
>
> but the bean:write writes nothing to the screen (i.e the column comes up empty).
> It looks like there might be a context problem since doing a bean:write in
> the layout jsp works but not in the tile header.jsp. There are no error messages
> at runtime.
>
> Does anyone know how I can accomplish this? My main goal is to use the same
> layout for every content page and have the option of dynamically displaying the screenName
> each time the tile header.jsp is used.
>
> Thanks,
> SB
>
>
> ---------------------------------------------------------------------
> 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