<f:ajax render> not working via <composite:clientBehavior>

微笑、不失礼 提交于 2019-12-05 14:16:44

Any relative client ID which is specified in <f:ajax render> is resolved relative to the parent ClientBehaviorHolder component in the component tree. In your particular case, this is actually the <h:selectOneRadio>. The component with client ID reg-unknown is thus being sought in the same naming container parent as the <h:selectOneRadio>, which is the <cc:implementation> itself (you probably already know that composite components implement NamingContainer). However, the desired component isn't in there.

You'd better specify an absolute client ID instead (thus, starting with :, so that it would be sought relative to the UIViewRoot). You can achieve this in two general ways:

  1. Hardcode it (assuming that this all is inside a form with ID form):

    <h:form id="form">
        <question:yesNo ...>
            <f:ajax event="alter" render=":form:reg-unknown" />
        </question:yesNo>
        ...
        <h:panelGroup id="reg-unknown" ...>
            ...
        </h:panelGroup>
    </h:form>
    
  2. Reference UIComponent#getClientId() (in case ID of parent naming container isn't known):

    <h:form ...>
        <question:yesNo ...>
            <f:ajax event="alter" render=":#{regUnknown.clientId}" />
        </question:yesNo>
        ...
        <h:panelGroup binding="#{regUnknown}" ...>
            ...
        </h:panelGroup>
    </h:form>
    

This is indeed awkward. This was ever reported as Mojarra issue 1510, but they didn't consider it to be a bug as the composite component itself isn't supposed to know anything about other components outside the composite component (although the solution would be theoretically simple: if the <f:ajax render> doesn't start with : or @, then prefix it with the client ID of the composite component's parent).

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!