Introduction

  • how does a .plist for the navigation look like?
  • (
    	{
    		name = Root;
    		children = ("First Level Item");
    	},
            {
    		name = "First Level Item";
    		pageName = "FirstPage";
    
    		children = ("Second Level Item");
    
    		height = 19;
    		width = 90;
    	},
            {
    		name = "Second Level Item";
    		displayName = "^session.secondLevelDisplayName";
                    action = "session.createSomething";
    
    		height = 19;
    		width = 90;
    	}
    )
    
  • what do I do with it?
    You create a page wrapper like:
  • .html: 
    	<webobject name="Navigation"/><webobject name="Content"/>
    .wod: 
    	Navigation: ERXNavigationMenu {context = myContext;}
    	Content: WOComponentContent {}
    .java:
    	...
        public NSKeyValueCoding navigationContext() {
            NSKeyValueCoding context = (NSKeyValueCoding)session().objectForKey("navigationContext");
            
            if (context().page() instanceof D2WPage) {
                context = ((D2WPage)context().page()).d2wContext();
            }
    		return context;
    	}	
    	

    The important thing is that if you provide a context, then the context needs to be able to find out the current state. So, in the case of a D2WContext you would check if the pageConfigiration is a given value and return the "path" to this "page" in the rules. If you don't give a context, then you need to set the state explicitely: given the example above, you need to write:
    public Session ...
    	public WOComponent createSomething() {
    		ERXNavigationManager.manager().navigationStateForSession(session()).setState(new NSArray(new Object[] {
    			"First Level Item",
    			"Second Level Item"
    		}));
    		... do real action...
    	}
    ...