Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
sree javab
Greenhorn
Posts: 9
  • 0
  • 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
  • 0
  • 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
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic