0

I have a composite (as in xmlns:composite="http://java.sun.com/jsf/composite"). I call it via

<comps:cimgx imgId="imA" flav="r" />

(for example) on a page. Is there a way to reference all html-objects generated by this composite, client-side via javascript?

Something like

window.document.getElementsBy_magic_jsf_tagType("comps.cimagx");

Edit: or within the composite as something like

#{cc.JSF_tag_type_name}

??

Edit2: For the background why I'm asking this, see Is it possible to add a javascript function to a h:form in jsf2?

Community
  • 1
  • 1
Gyro Gearloose
  • 1,056
  • 1
  • 9
  • 26

1 Answers1

0

JS knows nothing about server side code responsible for producing the HTML output on which the HTML document object model is based. This information has really to end up in HTML in some way. For abstraction, make use of CSS classes.

<cc:implementation>
    <div id="#{cc.clientId}" class="comp-cimgx">
        ...
    </div>
</cc:implementation>
var cimgxs = document.getElementsByClassName("comp-cimgx");

(note: getElementsByClassName() is not supported in IE8 and lower, grab jQuery 1.x if necessary)

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555