Hi Simon, You are right. But as I have mentioned i am binding the DIV component with a property in the backing bean instead of getting the UIViewRoot and then invoking findComponent.
It does give me the proper instance of the DIV component I tried to add a dummy DIV component outside the outer DIV component. In the rendered property of the dummy DIV component I called the method which will add children for DIV component with id="subnavigation" which is also retrieved using value binding. This will ensure that DIV components are constructed before the dummy DIV component's method is invoked. The method gets invoked, children get added but the left menu is not rendered. I guess I will have to create a custom component just to add something programmatically to the JSF tree. This sucks!! > -----Original Message----- > From: Simon Kitching [mailto:[EMAIL PROTECTED] > Sent: Thursday, December 14, 2006 11:08 AM > To: MyFaces Discussion > Subject: Re: Problems while programmatically adding components > > Madhav Bhargava wrote: > > Hi Simon, > > > > Yes the outer DIV component with id="subnavigation_outer" is enclosed in > > a subview naming container in the layout.jsp. Following is the code > > snipped: > > > > <td width="170px" valign="top" bgcolor="#F8F6F7" nowrap="nowrap"> > > <f:subview id="leftnav"> > > <tiles:insert attribute="leftnavigation" flush="false"/> > > > > </f:subview> > > </td> > > > > Do you mean to say that in my JSP for left navigation I need to prefix > > the naming container id if any? Why is this necessary? > > > > As you can see from the code below I get the inner DIV component via > > value binding. It gets me the correct component. > > > > I am able to populate and add a HtmlPanelNavigationMenu to the DIV > > component. If then I look at the entire tree then the components added > > are present. > > > > If the components are added properly then when it goes to the render > > response phase then it should get all the components. > > > > > > I am missing something or have I misunderstood something. > > See the documentation for findComponent here: > > http://myfaces.apache.org/api/apidocs/javax/faces/component/UIComponentB as > e.html > > Because you are searching against the UIViewRoot, you need to provide > the full path to the component you want to find. If you do the search > against the direct NamingContainer ancestor of the component (or use any > sibling of the component you are searching for), you only need the base > id of the component. > > Regards, > > Simon **************** 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***