Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Keerthi P
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Samuel March
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java.util.List uses and enumerator , also you may need to sort a list.



do your for loop with this





or

 
Keerthi P
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


is same as

 
Keerthi P
Ranch Hand
Posts: 203
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic