aspose file tools*
The moose likes JSF and the fly likes Custom component with children - Child component added at end appears as first child when rendered. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Custom component with children - Child component added at end appears as first child when rendered." Watch "Custom component with children - Child component added at end appears as first child when rendered." New topic
Author

Custom component with children - Child component added at end appears as first child when rendered.

Keerthi P
Ranch Hand

Joined: Aug 19, 2003
Posts: 203
I have a custom JSF component that renders navigation links. The following is a typical usage of the component:


And, the rendered content will appear as following, similar to the navigation links at the top of this page:

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:


The backing bean has an action method formSubmitted() that adds a child (HtmlNavigationLink) component to the parent (HtmlNavigationBar) dynamically. I thought that this newly added child would be the last child (as it is 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

As noted in the comment above, while the link 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?


Cheers.<br />Keerthi<br />(SCJP, SCWCD, SCBCD)
Samuel March
Ranch Hand

Joined: Oct 28, 2009
Posts: 39
java.util.List uses and enumerator , also you may need to sort a list.



do your for loop with this





or


...did you have the fish?!............................ No.
Keerthi P
Ranch Hand

Joined: Aug 19, 2003
Posts: 203


is same as

Keerthi P
Ranch Hand

Joined: Aug 19, 2003
Posts: 203
I have posted a simplified case of the issue here https://issues.apache.org/jira/browse/MYFACES-2392 and here
https://facelets.dev.java.net/issues/show_bug.cgi?id=358

If anyone has any clue, please advise.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Custom component with children - Child component added at end appears as first child when rendered.