Hi Keerthi, Can you post your getter code for the navigation bar please? Make sure it simply return null. My hunch is that your backing bean acts also as the component factory (which can incredibly bad).
p.s. This post belong to the user list. Dev lists on Apache are for those developing the product. You may be a developer, but from Apache MyFaces perspective, you're an user. Regards, ~ Simon On Tue, Oct 27, 2009 at 9:31 AM, <[email protected]> wrote: > > I have a custom JSF component that renders navigation links. The following > is a typical usage of the component: > > <custom:navigationBar id="navbar" spacing="2" > actionListener="#{testBean.navigationLinkClicked}" immediate="true" > binding="#{testBean.navigationBar}"> > <custom:navigationLink id="primaryData" value="Primary Data"/> > <custom:navigationLink id="principals" value="Principals" > active="true"/> > <custom:navigationLink id="administrators" value="Administrators"/> > <custom:navigationLink id="custodians" value="Custodians"/> > <custom:navigationLink id="accountingFirms" value="Accounting > Firms" clickable="false"/> > <custom:navigationLink id="lawFirms" value="Law Firms" > clickable="false"/> > <custom:navigationLink id="billing" value="Billing" > clickable="false"/> > </custom:navigationBar> > > And, the rendered content will appear as following: > > Primary Data | Principals | Administrators | Custodiams | Accounting Firms > | Law Firms | Billing > > > As you notice, the navigationBar component is bounded to > #{testBean.navigationBar} which is defined as below in the Backing bean: > > public class TestBean { > > private HtmlNavigationBar navigationBar; > .... // -- getter & setter for navigationBar > > public String formSubmitted() { > HtmlNavigationLink link = new HtmlNavigationLink(); > link.setId("link"); > link.setValue("New link"); > > navigationBar.getChildren().add(link) > > return null; > } > } > > > The backing bean has an action method formSubmitted() that adds a child > (HtmlNavigationLink) component to the parent (HtmlNavigationBar) > dynamically. This method is invoked on form submit. I thought that this > newly added child would be the last child (as it was added to end of the > children list). But, when the navigationBar renders its children, the > HtmlNavigationLink 'New link' appears as the first child causing the content > rendered as below: > > > New Link | Primary Data | Principals | Administrators | Custodiams | > Accounting Firms | Law Firms | Billing > > The following is the encodeChildren() method of *HtmlNavigationBar* > > @Override > public void encodeChildren(FacesContext context) throws IOException > { > ResponseWriter writer = context.getResponseWriter(); > List<UIComponent> children = getChildren(); > int count = children.size(); > > for (int i = 0; i < count; i++) { > UIComponent child = children.get(i); // -- why does > 'New link' appear at index == 0? > if (child instanceof HtmlNavigationLink) { > child.encodeAll(context); > } > } > } > > As noted in the comment above, while the child component was added to the > end of the list in the action method, it appears at index position 0 as the > first child? Why is it so? > > ________________________ > Keerthi Panneerselvam > Development Delivery - NetxOffice > iNautix Technologies India Private Limited, an affiliate of Pershing LLC, a > subsidiary of The Bank of New York Mellon Corporation > www.inautix.co.in > Office: 612-6696 (V) > Email: [email protected]
