You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Seth Milder <mr...@physics.gmu.edu> on 2004/10/27 06:13:05 UTC

Re: tiles-definition - role association issue

Ashutosh Satyam wrote:
> As per the Tiles Definition file syntax
>  In the tiles definition we can specify the role 
>  (Role to be checked when definition will be inserted in a page.)
>   
> Similarly, It is possible to associate a role with tiles: put attribute.
> 
> I'm intending to allow the definition to be used based on the role.
> 
> The second scenario works fine for me.
> I have my Login page for the application as stated below.
> 
> <%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>
> 
> <tiles:insert page="/WEB-INF/mainLayout.jsp" flush="true">
>     <tiles:put name="title" value="Welcome Page"/>
>     <tiles:put name="mainMenu" value="/adminMenupanel.jsp" role="admin"/>
>     <tiles:put name="mainMenu" value="/mgrMenupanel.jsp" role="manager"/>
>     <tiles:put name="mainMenu" value="/usrMenupanel.jsp" role="usr"/>
>     <tiles:put name="mainHeader" value="/header.jsp"/>
>     <tiles:put name="mainBody" value="/body.jsp"/>
>     <tiles:put name="mainFooter" value="/footer.jsp"/>
> </tiles:insert>
> 
> Depending upon the user's role, correct definition is inserted.
> 
> Now going on the same lines, when I have a definition with role specified, it  
> doesn't seem to work. My tiles-definition is as follows.
> 
> <definition name="baseDef" path="/WEB-INF/mainLayout.jsp" >
>     <put name="title" value="Tomcat Server" />
>     <put name="header" value="/header.jsp"/>
>     <put name="menu" value="/menupanel.jsp"/>
>     <put name="tab" value=""/>
>     <put name="body" value=""/>
> </definition>
> 
> <definition name="Add" extends="baseDef" role="admin">
>     <put name="tab" value="/WEB-INF/pages/tab.jsp"/>
>     <put name="body" value="/WEB-INF/pages/body.jsp"/>
>  </definition>
> 
> This definition (Add) gets applied for each of my role, though I was presuming that
> only for the user with 'admin' role this definition will be executed.
> 
> What am I missing? Is it not a correct approach?
> Kindly give some solution to achieve it.
> 
> 
> Regards,
> Ashutosh

I too have a similar issue. I would like to have a definitions file like 
this:

<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration//EN"
"http://jakarta.apache.org/struts/dtds/tiles-config.dtd">

<tiles-definitions>
   <!-- Base Definition -->
   <definition name="baseDef" 
path="/WEB-INF/jsp/templates/extranet_template.jsp">
     <put name="title"   value="Welcome to OpenTAC" direct='true'/>
     <put name="header"  value="/WEB-INF/jsp/includes/header.jsp"/>
     <put name="menu"    value="/WEB-INF/jsp/includes/menu.jsp"/>
     <put name="submenu" value="/WEB-INF/jsp/includes/submenu.jsp"/>
     <put name="content" value="/WEB-INF/jsp/student_welcome.jsp" 
role="STUDENT"/>
     <put name="content" value="/WEB-INF/jsp/moderator_welcome.jsp" 
role="MODERATOR"/>
     <put name="content" value="/WEB-INF/jsp/instructor_welcome.jsp" 
role="INSTRUCTOR"/>
     <put name="content" value="/WEB-INF/jsp/administrator_welcome.jsp" 
role="ADMINISTRATOR"/>
   </definition>


Even though the tiles.tld has role as a valid attribute for a put tag, 
as well as it existing in the struts docs, the above violates the DTD. 
The DTD does allow for the role attribute in the definition DTD, but 
this is not nearly as useful for my purposes. I think this is something 
that should be fixed as it seems to be an inconsistency.

Maybe I am missing something?


Thanks! And Struts is otherwise great!

Seth

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