Search code examples
javajavascriptjsfrichfaces

How to select all elements of the same kind in RichFaces


As far as I know, there are several functions in RichFaces that allow to get a reference to a "rich:" component by its id from javascript. But in my case I can have arbitrary amount of collapsiblePanels and need a way to expand them all upon a button click. Is there a solution?


Solution

  • Richfaces does not offer such a function. You can try to use JQuery to query for the class .rf-cp that is common to the CollapsiblePanel and try to get it from there.

    Of course, since all of the "arbitrary number" of panels will come from your code, I think that maybe it would be safer to, each time a new panel is created by your .xml, you add its id somewhere (Javascript code, hidden field, etc.) and use it from there.

    The list of richfaces available functions: http://docs.jboss.org/richfaces/latest_4_2_X/Component_Reference/en-US/html_single/#chap-Component_Reference-Functions