Search code examples
portalgatein

how to create a navigation in GateIn programatically


I created a GateIn portal application using GateIn 3.2. I need to create a navigation link in my gatein portal application without changing navigation.xml file. Which means i need to create it in pragmatically. To do that which GateIn service class i need to call?. Is there is any sample code available for that?


Solution

  • AFAIK from version 3.3 Gatein introduced the NavigationService that's used to manipulate navigation. Example for usage of NavigationService:

    POMSessionManager mgr = (POMSessionManager) container.getComponentInstanceOfType(POMSessionManager.class);
    NavigationServiceImpl service = new NavigationServiceImpl(mgr);
    
    mgr.getPOMService().getModel().getWorkspace().addSite(ObjectType.PORTAL_SITE, "save_navigation");
    NavigationContext nav = new NavigationContext(SiteKey.portal("save_navigation"), new NavigationState(5));
    
    service.saveNavigation(nav);
    

    For more details you should take a look at NavigationService & all its testcases in version 3.3 (or later). And they were in Component/Portal module.