Hallo, Cedric!
Another solution is to add an attribute to mypage, and let the layout pass this attribute to the menu:This is good but not perfect! :-(
<definition name="mypage" extends="layout">
<put name="menu" value="menu"/>
<put name="page.name" value="mypage" />
<put name="body" value="/myBody.jsp"/>
</definition>
and in layout.jsp:
<tiles:insert attribute="menu" >
<tiles:put name="activeMenu" beanName="page.name" beanScope="tile"/>
</tiles:insert>
Why do I can't simply specify the attribute for definition, which I use as attribute in definitions file. I suppose, it's easy to use something like
<component-definitions>
<definition name="layout.empty" path="/layout/empty.jsp">
<put name="title" value=""/>
<put name="head" value="layout.head"/>
<put name="body" value=""/>
</definition>
<definition name="layout.head" path="/layout/head.jsp">
<put name="title" value=""/>
<put name="css" value="/css/ksci.css"/>
<put name="js" value="/js/ksci.js"/>
</definition>
<definition name="layout.body" path="/layout/body.jsp">
<put name="userinfo" value=""/>
<put name="menuplace" value=""/>
<put name="content" value=""/>
</definition>
<definition name="layout.simple" extends="layout.empty">
<put name="userinfo" value=""/>
<put name="menuplace" value=""/>
<put name="content" value=""/>
<put name="body" value="layout.body">
<put name="content" beanName="content" beanScope="tile"/>
</put>
</definition>
<definition name="test" extends="layout.simple">
<put name="title" value="page.title.test"/>
<put name="content" type="string" value="Hello, World!" />
</definition>
</component-definitions>
Here I mean lines:
<put name="body" value="layout.body">
<put name="content" beanName="content" beanScope="tile"/>
</put>
As you see the layout.empty is the extension of layout.empty. In layout.empty I have no attribute content, I add this attribute in layout.simple because I'd like to pass this attribute to the body which actually is layout.body. And layout.body has attribute content. So, I have no jsp file for layout.simple and I can't use the technique, you proposed in your post.
Is it really impossible to pass the definition attribute to subdefinition as attribute (in definition file)?
I really miss this feature, plase help me or poit me how can I realize the same functions!
Thanks a lot for your advise!
Igor Lyubimov wrote:Hallo, All!
I'm trying to use struts with tiles framework. The idea of tiles definitions seems to be very good. But I can't find how is it possible to pass the attributes to the definitions, which I use as attribute.
Here is an example with the explanation of my problem:
Suppose, I need to build the portal with the classical layout (header, left side menu, content and footer).
I've made the following definitions for this layout
------------------------------------------------------------
<definition name="layout" path="/layout.jsp">
<put name="header" value="/header.jsp"/>
<put name="menu" value="menu"/>
<put name="body" value=""/>
<put name="footer" value="/footer.jsp"/>
</definition>
<definition name="menu" path="/menu.jsp">
<put name="activeMenu" value=""/>
</definition>
------------------------------------------------------------
The activeMenu attribute for menu definition says to menu which item
should be marked as active for current page.
Suppose, I have the following definition for my page
------------------------------------------------------------
<definition name="mypage" extends="layout">
<put name="menu">
<insert beanName="menu">
<put name="activeMenu" value="mypage"/>
</insert>
</put>
<put name="body" value="/myBody.jsp"/>
</definition>
------------------------------------------------------------
This definition is broken (attribute "menu"), but I need to pass the
attribute for menu definition as a parameter. How can I do this?
I whant to pass the active menu name as an attribute for menu in each
page (they all look like mypage).
Or is it impossible in tiles definitions to pass attributes this way?
Probably exists a workaroud for this cases?
Thanks,
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- _____________________________________________________________________ | | | knipp | Knipp Medien und Kommunikation GmbH ------- Technologiepark Martin-Schmeisser-Weg 9 D-44227 Dortmund Dipl.-Mathematiker Igor Lyubimov Fon: +49-231-9703-0 [EMAIL PROTECTED] Fax: +49-231-9703-200 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - C e B I T 2003 Besuchen Sie uns H a n n o v e r auf unserem Stand: 12.3.-19.3.2003 Halle 6, C 52/560 --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]