Hi All,
 I am new to tiles frame work. I've applied tiles throughout my project. My 
layout is very commonly used and it includes header, left navigation bar, 
main body and footer. I've defined all the JSP pages in
*tiles-defs.xml*file. I'm providing part of
*tiles-defs.xml, layout.jsp *(default layout page)*, navBar.jsp* (left 
navigation bar).

 Now, what I would like to do is highlighting a section in navigation bar 
which depends on the parameter I'm passing from *tiles-defs.xml* file.

 *tiles-defs.xml:*

* *

<!-- Layout Definitions -->

<definition name=".mainLayout" path="/pages/include/layout.jsp">

<put name="title" value="CDP Struts Template" />

 <put name="header" value="/pages/include/header.jsp" />

 <put name="footer" value="/pages/include/footer.jsp" />

<put name="navBar" value="/pages/include/navBar.jsp" />

 <put name="body" value="/pages/log.jsp" />

 </definition>

 <!-- End of Layout definitions -->

 <definition name=".refCodeEdit" extends=".mainLayout">

 <put name="title" value="Add/Edit Reference Codes"/>

 <put name="body" value="/pages/refCodeEdit.jsp"/>

<put name="section" value="user"/>

 </definition>

...

...

And so on......

  *layout.jsp:*

 <%@ *taglib* *uri*="/WEB-INF/struts-html.tld" *prefix*="html"%>

<%@ *taglib* *uri*="/WEB-INF/struts-tiles.tld" *prefix*="tiles"%>

<%@ *taglib* *uri*="/WEB-INF/struts-logic.tld" *prefix*="logic"%>

<%@ *taglib* *uri*="/WEB-INF/struts-bean.tld" *prefix*="bean"%>

<html:html xhtml="true">

<head>

<title>CDP Struts Template</title>

<link href="pages/include/style.css" rel="stylesheet" type="text/css" />

</head>

<body>

<tiles:insert attribute="header">

<tiles:put name="title" beanName="title" beanScope="tile"/>

</tiles:insert>

<table border="0" cellpadding="5" cellspacing="0" style="height:80%;" 
width="100%">

<tr><td width="150" valign="top" align="left" class="leftnavbar">

<tiles:insert attribute="navBar">

<tiles:put name="section" beanName="section" beanScope="tile"/>

</tiles:insert>

</td>

<td valign="top">

<tiles:insert attribute="body"/>

</td>

</tr>

</table>

<tiles:insert attribute="footer"/>

</body>

</html:html>

  *navBar.jsp:*

 <ul>

<li><a href="ManageUser.do" <% if (siteSubSection.equals("user")) { %> 
class="current" <%}%>> Reference Codes </a></li>

</ul>

 Here, I'm passing the parameter <put name="section" value="user"/> from the 
XML file and passing again from *layout.jsp* to *navBar..jsp*. In *
navBar..jsp*, I would like to compare the value of the parameter and then 
highlight the section, like - <a href="ManageUser.do" <% if (
siteSubSection.equals("user")) { %> class="current" <%}%>> Reference Codes 
</a>. But I couldn't find a way to do it because we can only get the 
parameter value as <tiles:getAsString name="section" />. Is there any way to 
get the value as Java String so that I can do the String comparison? Or any 
other way to highlight sections using tiles? I'm not sure if I've explained 
it properly. Please ask me if not.

 Thanks,

 Anindya
  • tiles problem Anindya Bandyopadhyay

Reply via email to