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
import java.util.Map;
import javax.servlet.jsp.jstl.sql.Result;
import net.sf.navigator.menu.MenuComponent;
import net.sf.navigator.menu.MenuRepository;
public class 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
[email protected]
https://lists.sourceforge.net/lists/listinfo/struts-menu-user