incubator-adffaces-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Causevic, Dzenan" <>
Subject actionListener for navigation tabs
Date Mon, 30 Oct 2006 14:22:16 GMT

I use both actionListener (to set focus on selected tab, and set navigation case outcome corresponding
to this tab by detecting its id value) and action (to return outcome string stored in the
bean by actionListener) and navigation is okay now. I get moved to correct pages by clicking
on its tabs, HOWEVER now the tabs are not being selected correctly. I move to a right page
but the wrong tab is being selected. And it seems to be delayed by one click. Namely the focus
of selected tabs get on the one that I previously clicked on. Now I found out after some testing
that this happens because I am loading different jsp files every time I click on the tab.
If I reload the same jsp page (I set all tabs to point to the one same jsp page) tabs are
being selected correctly.

This makes me think there is an issue with page scope and tab component. Seems to me that
every time I load different jsp page (they are all including common code section for tabs),
a new instance of tab component object is being created and it has no way of tracking its
state from the previous page. Shouldn't these tab component objects be STATIC so that they
retain their values across multiple pages. I mean shoudn't all different pages be refferencing
one same object instance created when the first page containing tab components was loaded.
And shouldn't all subsequent (different) jsp pages be still refferencing that same object?

Is there a way to make every tab component object STATIC across different jsp pages? Am I
missing something from the code below?

This is code from my JSP page that implements trinidad tab navigation components:

<tr:navigationPane hint="tabs">
      <tr:commandNavigationItem id="login" text="Home" actionListener="#{commandNavigationItem.navigationItemAction}"
action="#{navigationCaseBean.getCaseValue}" selected="true"/>
      <tr:commandNavigationItem id="codeOfCond" text="Code of Conduct" actionListener="#{commandNavigationItem.navigationItemAction}"
      <tr:commandNavigationItem id="personalInfo" text="Personal Info" actionListener="#{commandNavigationItem.navigationItemAction}"
      <tr:commandNavigationItem id="moreInfo" text="More Info" actionListener="#{commandNavigationItem.navigationItemAction}"

faces-managed-beans.xml is as following:



import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.faces.component.UIComponent;
import javax.faces.event.ActionEvent;
import org.apache.myfaces.trinidad.bean.FacesBean;
import org.apache.myfaces.trinidad.bean.PropertyKey;
import org.apache.myfaces.trinidad.component.UIXCommand;
import org.apache.myfaces.trinidad.component.UIXNavigationHierarchy;
import org.apache.myfaces.trinidad.context.RequestContext;
import org.apache.myfaces.trinidad.bean.FacesBean.Type;

 * @author dcausevic
public class CommandNavigationItemBean {
    /** Creates a new instance of CommandNavigationItemBean */
    public CommandNavigationItemBean() {
    public void navigationItemAction(ActionEvent event)
        UIComponent actionItem = event.getComponent();
        NavigationCaseBean navCase = new NavigationCaseBean();        
        } else if (actionItem.getAttributes().containsValue("codeOfCond")){
        } else if (actionItem.getAttributes().containsValue("personalInfo")){
        } else if (actionItem.getAttributes().containsValue("moreInfo")){
        UIComponent parent;        
        for(parent = actionItem.getParent(); !(parent instanceof UIXNavigationHierarchy);)
            parent = parent.getParent();
            if(parent == null)
                System.err.println("Unexpected component hierarchy, no UIXNavigationHierarchy
        List children = parent.getChildren();
        Iterator i$ = children.iterator();
            UIXCommand child = (UIXCommand)i$.next();
            FacesBean childFacesBean = child.getFacesBean();
            Type type = childFacesBean.getType();
            PropertyKey selectedKey = type.findKey("selected");            
            if(selectedKey != null)
                childFacesBean.setProperty(selectedKey, Boolean.valueOf(child == actionItem));
        } while(true);
        RequestContext adfContext = RequestContext.getCurrentInstance();

action bean

 * @author dcausevic
public class NavigationCaseBean {
    /** Creates a new instance of NavigationCaseBean */
    public NavigationCaseBean() {

    private static String caseValue;

    public void setCaseValue(String caseValue) {
        this.caseValue = caseValue;

    public String getCaseValue() {
        return caseValue;



  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message