Thanks a ton for your reply Matt. I do not get the error now, but it is 
redirecting to some other page, while i work on that.
 
Can you please guide me on how i can fetch my menu items from database instead 
of menu-config.xml
 
thanks,
Gokul

--- On Wed, 4/1/09, Matt Raible <m...@raibledesigns.com> wrote:


From: Matt Raible <m...@raibledesigns.com>
Subject: Re: [struts-menu] Struts 2 dynamic menu issue
To: "General mailing list for Struts Menu" 
<struts-menu-user@lists.sourceforge.net>
Date: Wednesday, April 1, 2009, 11:47 PM


Instead of registering it in your Spring applicationContext, I'd try using the 
MenuContextListener in your web.xml:



    <listener>
        
<listener-class>net.sf.navigator.menu.MenuContextListener</listener-class>
    </listener>


If that doesn't work, look for errors on startup - you might be missing some 
required JARs.


Matt

On Wed, Apr 1, 2009 at 10:39 PM, Jayaram Gokulan <karam...@yahoo.com> wrote:






Hi,
I use Struts2, Spring and hibernate in my project wanted to integrate Struts 
menu, the dynamic roles from oracle db. I followed the link
 
http://demo.raibledesigns.com/struts-menu/dynamicMenu.jsp
 I copy pasted the code snippet into an action
 
importjava.util.Map; 

importjavax.servlet.jsp.jstl.sql.Result; 

importnet.sf.navigator.menu.MenuComponent; 
importnet.sf.navigator.menu.MenuRepository; 

publicclass MenuBuilderAction extends BaseAction { 


/** 
* 
*/ 
private static final long serialVersionUID = 1L; 

MenuRepository 
repository = new MenuRepository(); 


// Get the repository from the application scope - and copy the 
// DisplayerMappings from it. 
MenuRepository defaultRepository = (MenuRepository) getSession() 
.getAttribute(MenuRepository.MENU_REPOSITORY_KEY); 


//repository.setDisplayers(defaultRepository.getDisplayers()); 

Result 
result = (Result) getSession().getAttribute("menus"); 

Map[] 
rows = result.getRows();{ 


for (int i = 0; i < rows.length; i++) { 
MenuComponent mc = new MenuComponent(); 
Map row = rows[i]; 
String name = (String) row.get("name"); 
mc.setName(name); 
String parent = (String) row.get(
"parent_name"); 
System.out.println(name + ", parent is: " + parent); 
if (parent != null) { 
MenuComponent parentMenu = repository.getMenu(parent); 
if (parentMenu == null) { 
System.out.println("parentMenu '" + parent 
+ "' doesn't exist!"); 
// create a temporary parentMenu 
parentMenu = new MenuComponent(); 
parentMenu.setName(parent); 

repository.addMenu(parentMenu); 
} 

mc.setParent(parentMenu); 
} 
String title = (String) row.get(



"title"); 
mc.setTitle(title); 
String location = (String) row.get(
"location"); 
mc.setLocation(location); 

repository.addMenu(mc); 
} 
getSession().setAttribute(
"repository", repository); 
} 
}

 
My menu-config.xml
 
<?xml version="1.0" encoding="UTF-8"?> 
<MenuConfig> 
<Displayers> 
<Displayer name="Velocity" 
type="net.sf.navigator.displayer.VelocityMenuDisplayer"/> 
</Displayers> 
<Menus> 
<Menu name="MainMenu" title="mainMenu.title" page="/mainMenu.html" 
roles="ROLE_ADMIN,ROLE_USER"/> 


</Menu> 
</Menus> 
</MenuConfig> 
  
ApplicationConfig.xml 
<bean id="menu" class="net.sf.navigator.menu.MenuLoader"> 
<property name="menuConfig"> 
<value>/WEB-INF/menu-config.xml</value> 
</property> 
</bean> 
 
When i run my jsp i get
 
javax.servlet.jsp.JspException: The menu repository could not be found. 
 
Kindly help
thanks,
Gokul
 



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

_______________________________________________
struts-menu-user mailing list
struts-menu-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/struts-menu-user



-----Inline Attachment Follows-----


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

-----Inline Attachment Follows-----


_______________________________________________
struts-menu-user mailing list
struts-menu-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/struts-menu-user



      
------------------------------------------------------------------------------
_______________________________________________
struts-menu-user mailing list
struts-menu-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/struts-menu-user

Reply via email to