Search code examples
javajsfjsf-2faceletscomposite-component

JSF 2.0(Primefaces) - composite component is unreachable, if to refer by ID


Have simple composite component(compositeComponent.jsf),that is embedded to global.jsf page.

The problem is that ajax can't update this component. Neither :componentId, not formId:componentId declaration doesn't work.

Should i write own method generator in my bean for id generation?

see pic. for more info! alt text


Solution

  • Open page in browser, rightclick and choose View Source. Locate the generated HTML of <h:outputText> and determine its generated client ID. You should in fact be using exactly this ID with the : prefix. Let's bet that the first part of the ID turns out to be autogenerated. This can happen if you didn't give your composite component a fixed ID. You need to do this as well:

    <my:compositeComponent id="ccId" />
    

    then you can locate it as follows:

    <p:ajax update=":ccId:cCart:cId" />