Hi David,

Thanks for a quick response. I changed the way encoding is done to what you 
have suggested.
I have overridden the getRendersChildren method to return true so that 
encodeChildren of this custom component will only get called.

However if you look at the code of HtmlNavigationMenuRenderer - renderer for 
<t:panelNavigation2> you will find that getRenderesChildren will return true. 
This means that in the method that you have provided following will happen:

Note: There is only one child HtmlPanelNavigationMenu for this custom 
component. This component in turn has many HtmlCommandNavigationItem components.

1. child.encodeBegin gets called
2. child.encodeChildren gets called
3. child.encodeEnd gets called.

Child component passed is HtmlPanelNavigationMenu.

Unfortunately nothing changes. Problems persist the way they were.

Rgds,
madhav

> -----Original Message-----
> From: David Delbecq [mailto:[EMAIL PROTECTED]
> Sent: Wednesday, January 03, 2007 7:24 PM
> To: MyFaces Discussion
> Subject: Re: <t:panelNavigationMenu2> does not work properly when added
> programmatically- Any help
>
> En l'instant précis du 01/03/07 14:17, Madhav Bhargava s'exprimait dans
> toute sa noblesse:
> >
> > Hi All,
> >
> >
> >
> > In the encodeBegin method of this custom component the
> > <t:panelNavigation2> component is constructed programmatically.
> >
> >
> >
> > In the Renderer for this custom component encodeBegin looks like:
> >
> >
> >
> > checkState(context, component);
> >
> > super.encodeChildren(context, component);
> >
> > //Call encodeChildren 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();
> >
> >                         childComponent.encodeChildren(context);
> >
> The above line is suspicious. If you want to handle yourself your
> component's child rendering process, you must do it more cleanly. Most
> component don't render their childs by themselve. Most probably, your
> call to encodeChildren() only do a partial work, explaining difference
> you get.
>
> Here is an example code i use when i need in a custom rendered to manage
> myself rendering of childrens:
>
>     private void encodeChild(FacesContext context,UIComponent child)
> throws IOException{
>
>         if (!child.isRendered())
>         {
>             return;
>         }
>
>         child.encodeBegin(context);
>         if (child.getRendersChildren())
>         {
>             child.encodeChildren(context);
>         }
>         else
>         {
>             for (int i = 0;i< child.getChildren().size(); i++)
>                 encodeChild(context,
> (UIComponent)child.getChildren().get(i));
>         }
>         child.encodeEnd(context);
>     }
>
> Just call this method when you need to render one of your childs.
> don't forget to override the getRendersChildren() and encodeChildren()
> of your custom component btw.


**************** 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***

Reply via email to