Hi,

I am implementing a struts application with menu lists which need to be
dynamic based on a user role hierarchy, i.e not a simple user role = menu
list. Therefore I cannot set up menu lists in the tile definitions file as
they are

I hold the menu list in a database which I am accessing via an EJB and
returning to the session using a vector of DAO object 's which contain the
basic information about each menu item, i.e name, link,type (we have
different types of links some open a pop-up window, others run an inline
java applet)

Currently I am using standard Java scriptlets to access the vector and
print it out in the JSP tile page example below:

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="/struts/tiles" prefix="tiles" %>
<%@ taglib uri="/struts/logic" prefix="logic" %>
<%@ taglib uri="/struts/bean" prefix="bean" %>
<%@ taglib uri="/struts/html" prefix="html" %>
<%@ page import="com.csc.ebilling.ejb.common.MenuItemDAO" %>
<%
     String commonImagePath= request.getContextPath()
+"/presentation/DEFAULT/images";
     String currentPageName = (String)session.getAttribute
("currentPageName");
     java.util.Vector topMenu = (java.util.Vector) session.getAttribute
("topMenu");
%>

<table>
<tr>

<%
  for (int i=0;i<topMenu.size();i++){
    // pageContext.setAttribute("topMenuItem", topMenuItem,
PageContext.PAGE_SCOPE);
    MenuItemDAO topMenuItem = (MenuItemDAO) topMenu.get(i);
    if (topMenuItem.getMenuItemName().equals(currentPageName))
    {
%>
  <td valign="bottom" align="right" class="tabselected">
             <img src="<%=commonImagePath%>/page_name_left_selected.gif"
border="0">
   </td>
    <td valign="bottom" background="
<%=commonImagePath%>/page_name_mid_selected.gif" align="center" class
="tabselected" nowrap style="background-repeat: repeat-x;">
        <span class="tabselected"><%=topMenuItem.getMenuItemName()%></span>
    </td>
  <td valign="bottom" align="left" class="tabselected">
        <img src="<%=commonImagePath%>/page_name_right_selected.gif" border
="0">
   </td>
<%
}
else
{
%>
  <td valign="bottom" align="right" class="tabunselected">
       <a href="<%=request.getContextPath()%>/changePage.do?pageName
=<%=topMenuItem.getMenuItemName()%>">
        <img src="<%=commonImagePath%>/page_name_left_unselected.gif"
border="0">
       </a>
  </td>
  <td valign="bottom" background="
<%=commonImagePath%>/page_name_mid_unselected.gif" align="center" class
="tabunselected" nowrap style="background-repeat: repeat-x;">
       <a href="<%=request.getContextPath()%>/changePage.do?pageName
=<%=topMenuItem.getMenuItemName()%>">
        <span class="tabunselected"><%=topMenuItem.getMenuItemName
()%></span>
       </a>
 </td>
  <td valign="bottom" align="left" class="tabunselected">
      <a href="<%=request.getContextPath()%>/changePage.do?pageName
=<%=topMenuItem.getMenuItemName()%>">
            <img src="<%=commonImagePath%>/page_name_right_unselected.gif"
border="0">
        </a>
  </td>

<%
 }
  }
%>

</tr>
</table>


I realise that this is not best practice and I should be using the tag-libs
but I'm struggling to make the tag-libs work, I'm also confused about
whether this tile needs to be inside a form as I am not actually submitting
anything (as in a Login page), however I do need to pass a pageName
parameter into the request.

The above example does work (sort of) however I am unable to extract the
pageName parameter in my action class as it keeps returning null

I would really appreciate some pointers as I thought I had struts figured
but I now realise I've gone wrong somewhere along the line

Regards

Joanne Corless

CSC Computer Sciences Limited
(   Office +44 (0)1772 318025
( Mobile +44 (0)7767 656588
* email [EMAIL PROTECTED]


Based at: CSC, Alliance House, Library Road, Chorley, Lancs, PR6 7EN
CSC Computer Sciences Limited: Registered in England, No. 963578.
Registered office: Royal Pavilion, Wellesley Road, Aldershot, Hampshire,
GU11 1PZ.


----------------------------------------------------------------------------------------

This is a PRIVATE message. If you are not the intended recipient, please
delete without copying and kindly advise us by e-mail of the mistake in
delivery. NOTE: Regardless of content, this e-mail shall not operate to
bind CSC to any order or other contract unless pursuant to explicit written
agreement or government initiative expressly permitting the use of e-mail
for such purpose.
----------------------------------------------------------------------------------------






---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to