1

We have build the following composite component, however we haven't found a way to make it rerender component external elements.

 <h:panelGroup id="#{cc.attrs.id}Cmtp" rendered="#{cc.attrs.rendered}">
      <div id="#{cc.attrs.id}" class="xyz-select #{cc.attrs.styleClass}" >
        <h:inputText id="input" disabled="#{cc.attrs.disabled}"
          value="#{cc.attrs.value}"
          tabindex="#{cc.attrs.tabindex}" maxlength="#{cc.attrs.maxlength}" 
          converter="#{cc.attrs.converter}">
          <a4j:ajax event="change" render="select" />        
        </h:inputText>
        <rich:select disabled="#{cc.attrs.disabled}"
          id="select" value="#{cc.attrs.value}"
          listWidth="#{cc.attrs.listWidth}"
          converter="#{cc.attrs.converter}">          
          <f:selectItems value="#{cc.attrs.items}" var="xyz"
            itemValue="#{xyz}" itemLabel="#{xyz.name}" />
          <a4j:ajax event="selectitem" render="input" />            
        </rich:select>
        </div>        
      </h:panelGroup>

I have tried adding an attribute defining the external elements to rerender however this just comes up with an error message that the ids are not within the scope of the component.

Composite component:

<a4j:ajax event="change" render="select #{cc.attrs.render}" />  

Def:

<xyz:selct ... render="idA idB" />

I have also tried to pass an to it, by exposing the clientBehavior in the interface.

Composite component Interface:

<composite:clientBehavior name="change" event="action" /> 

Def:

<xyz:select ..>
   <a4j:ajax event="change" rerender="idA idB" />
</xyz:select>

However this just stops all the ajax functionality of the component.

After the suggestion from BalusC (thank you) I have tried the following:

<composite:interface>
...
<composite:clientBehavior name="change" event="action" targets="input select"/>  
</composite:interface>

And tried passing it the following AJAX Tag:

<a4j:ajax event="change" render="idA idB" oncomplete="alert('tada');" />

Sadly none of the specified actions are performed.

dngfng
  • 1,923
  • 17
  • 34

1 Answers1

4

Relative client IDs (i.e. not starting with :) are resolved relative to the current parent NamingContainer component (e.g. <h:form>, <h:dataTable>, <cc:implementation>, etc).

So, in case of the following line inside your composite,

<a4j:ajax event="change" render="select #{cc.attrs.render}" />  

it's been is searched relative to the <cc:implementation>. However, there's no component with ID idA nor idB inside the <cc:implementation>.

You need to specify an absolute client ID instead. E.g.

<xyz:selct ... render=":formId:idA :formId:idB" />

See also:


As to the <cc:clientBahavior> fail, the context/SSCCE is missing, but I believe it's simply because you forgot execute attribute and mistyped render attribute.

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Well the full path resolution is not an option for us, since the components are heavily nested. The typo came along since I didn't copy and paste that code, so would work for me, I haven't quite understood what execute referrs to. What would the propper definition look like? – dngfng Aug 12 '13 at 12:34
  • Thanks for the pointers, but I must be missing something since its still not working, I tried the cc:clientBehaviour with target="input select" (see above). – dngfng Aug 13 '13 at 12:41
  • I don't do RichFaces, but this suggests that the components identified by `input` and `select` doesn't support a theoretically nested `` at all. Perhaps you need `valueChange` or just `change`? The `` must represent the **actual** event name which is to be used by the target components in order to fire the attached ``. The `` is fully free to your choice and should be used in `` of the attached ``. – BalusC Aug 13 '13 at 19:16
  • Thanks, you pointed me in the right direction, it should have been and not event="action". It works perfectly. – dngfng Aug 14 '13 at 07:51