Hi all,

similar to the demo navigation pane example, I'd like that the selected tab on 
my NavigationPane is highlighted if I click on it. I'm using facelets and a 
template that contains the layout. In the debug-mode, I can see that the 
commandNavigationItem backing bean is called and the selected property is set 
correctly. But after page refresh, nothing has been changed. Can anybody help?

Thanks

Here my faclet template:

               <tr:form id="mainNavForm">
               <tr:navigationPane hint="tabs" shortDesc="Whle Tab" 
id="mainNavBar">
                    <tr:commandNavigationItem id="mainNavItem1" text="home" 
action="home" partialSubmit="true"
                actionListener="#{commandNavigationItem.navigationItemAction}" 
/>
                                        <tr:commandNavigationItem 
id="mainNavItem2" text="Warenkorb" action="showOrder" 
rendered="#{securityContext.ifNotGranted['ROLE_ADMIN']}" partialSubmit="true"
                actionListener="#{commandNavigationItem.navigationItemAction}" 
/>
                                        <tr:commandNavigationItem  
id="mainNavItem3" text="Registrieren" action="register"  
rendered="#{securityContext.ifNotGranted['ROLE_CUSTOMER,ROLE_ADMIN']}" 
partialSubmit="true"
                actionListener="#{commandNavigationItem.navigationItemAction}"/>
                                        <tr:commandNavigationItem  
id="mainNavItem4" text="Kundenliste" action="showCustomer"  
rendered="#{securityContext.ifAnyGranted['ROLE_ADMIN']}" partialSubmit="true"
                
actionListener="#{commandNavigationItem.navigationItemAction}"/>                
          
                                        <tr:commandNavigationItem  
id="mainNavItem5" text="Meine Daten" action="#{customerAction.editCustomer}" 
rendered="#{securityContext.ifAnyGranted['ROLE_CUSTOMER']}" partialSubmit="true"
                
actionListener="#{commandNavigationItem.navigationItemAction}"/>                
          
                                        <tr:commandNavigationItem  
id="mainNavItem6" text="Meine Bestellungen" action="orderHistory" 
rendered="#{securityContext.ifAnyGranted['ROLE_CUSTOMER']}" partialSubmit="true"
                
actionListener="#{commandNavigationItem.navigationItemAction}"/>                
                                                                                
  
                                        <tr:commandNavigationItem  
id="mainNavItem7" text="Abmelden" action="#{customerAction.logout}"  
rendered="#{securityContext.ifAnyGranted['ROLE_CUSTOMER,ROLE_ADMIN']}" 
partialSubmit="true"
                
actionListener="#{commandNavigationItem.navigationItemAction}"/>                
                                                                                
                                  
                </tr:navigationPane>
               </tr:form>

and here my backing bean:

  @SuppressWarnings("unchecked")
  public void navigationItemAction(ActionEvent event)
  {
    UIComponent actionItem = event.getComponent();
    UIComponent parent = actionItem.getParent();
    while (! (parent instanceof UIXNavigationHierarchy) )
    {
      parent = parent.getParent();
      if (parent == null)
      {
        System.err.println(
          "Unexpected component hierarchy, no UIXNavigationHierarchy found.");
        return;
      }
    }

    List<UIXCommand> children = parent.getChildren();
    for (UIXCommand child : children)
    {
      FacesBean childFacesBean = child.getFacesBean();
      FacesBean.Type type = childFacesBean.getType();
      PropertyKey selectedKey = type.findKey("selected");
      if (selectedKey != null)
      {
          boolean isSelected = (child == actionItem);
        childFacesBean.setProperty(selectedKey, isSelected);
      }
    }

    RequestContext adfContext = RequestContext.getCurrentInstance();
    adfContext.addPartialTarget(parent);
  }

Reply via email to