This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

fetch each component on a JSF page and check if id attribute is there.  RSS feed

 
sree javab
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to fetch each component on a given JSF page and check if that component has an Id attribute. If the component has no Id attribute to it, then assign an attribute Id with a customised value. (this is required to be done in my project). I know in JSF, if no id attribute is specified a default id is given to components, but it is different every time. I want the Id attribute's value to be the same every time the page loads. (The JSF pages have been written long back with no id attributes to components.)
Can anyone please let me know what could be the best way to do it.
 
Max Jonas Werner
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi sree,

to answer your question, not taking into account that there could be a better solution to your actual problem (different IDs): What about fetching the UIViewRoot calling FacesContext.getCurrentInstance().getViewRoot() and then iterating over the children with UIViewRoots getChildren method. Fetching the children should then be implemented recursively e.g.

BTW: I find this a very ugly approach to solving your problem. You should probably consider a different solution which e.g. is not dependent on the IDs. Perhaps you can just explain the case in more detail.

HTH,
Max
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!