You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Madhav Bhargava <Ma...@infosys.com> on 2007/01/09 16:56:32 UTC

A little help - how do you prevent HtmlPanelNavigationMenu to restore open states

Hi All,



I have 2 custom components:



1.	TopBar Component - manages role and delegator selection via role
and delegator drop downs.
2.	Left Menu Component - Essentially a HtmlPanelNavigationMenu
component which will dynamically construct itself with
HtmlCommandNavigationItem based on combination of role and delegator



Steps to highlight the problem:



Imagine a user playing 2 roles



1.	Change the role from the top bar component role drop down and
click top bar button to process the change. The action method bound to
this component forwards the control to the home page for the new role
and does not return null.
2.	The Left Navigation now contains a new set of operations with
Home link selected. One of the operations is the same for both roles
which Opens to show second level operations. Call the operation "A"
3.	Select "A" so that it opens up. Now the second level of
operations under it are highlighted.
4.	Change the role from the role drop down and click the button to
process the change. This will cause the entire left navigation tree to
be constructed again with the new set of operations for a different
role.
5.	When the left navigation for the new selected role is displayed
it surprisingly retains the open items in the HtmlLeftNavigationMenu for
the previous view.



I tried to monitor where the left navigation's open property is set to
true and it turned out that soon after encodeBegin the property is set
to true again.



Here is how I encode the component:



public void encodeEnd(FacesContext context, UIComponent component)
throws IOException {

checkState(context, component);

            super.encodeEnd(context, component);

            //Call encodeEnd on all the child components of this
component

            List children = component.getChildren();

            if (null != children) {

                        Iterator childIter = children.iterator();

                        while(childIter.hasNext()) {

                                    UIComponent childComponent =
(UIComponent)childIter.next();

                                    encodeChild(context,
childComponent);

                        }

            }

}



private void encodeChild(FacesContext context, UIComponent child) throws
IOException {

            checkState(context, child);

            if (!child.isRendered()) {

                        return;

            }

            child.encodeBegin(context);

            if (child.getRendersChildren()) {

                        child.encodeChildren(context);

            } else {

                        for (int counter=0; counter <
child.getChildCount(); counter++) {

                                    encodeChild(context,
(UIComponent)child.getChildren().get(counter));

                        }

            }

            child.encodeEnd(context);

}



How can I prevent the open items to get restored?



Rgds,

Madhav



**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely for the use of the addressee(s). If you are not the intended recipient, please notify the sender by e-mail and delete the original message. Further, you are not to copy, disclose, or distribute this e-mail or its contents to any other person and any such actions are unlawful. This e-mail may contain viruses. Infosys has taken every reasonable precaution to minimize this risk, but is not liable for any damage you may sustain as a result of any virus in this e-mail. You should carry out your own virus checks before opening the e-mail or attachment. Infosys reserves the right to monitor and review the content of all messages sent to or from this e-mail address. Messages sent to or from this e-mail address may be stored on the Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***