Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ajax update/render does not work on a component which has rendered attribute

It's not possible to re-render (update) a component by ajax if the component itself is not rendered in first place. The component must be always rendered before ajax can re-render it. Ajax is using JavaScript document.getElementById() to find the component which needs to be updated. But if JSF hasn't rendered the component in first place, then JavaScript can't find anything to update.

The solution is to simply reference a parent component which is always rendered.

<h:form>
    ...
    <h:commandButton ...>
        <f:ajax ... render=":text" />
    </h:commandButton>
</h:form>
<h:panelGroup id="text">
    <h:outputText ... rendered="#{not empty user}" />
</h:panelGroup>

See also:

  • Why do I need to nest a component with rendered="#{some}" in another component when I want to ajax-update it?
  • How to find out client ID of component for ajax update/render? Cannot find component with expression "foo" referenced from "bar"