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.

Reply via email to