The problem is that you are confusing the concept of the attributes rendered
and disabled
of JSF.
rendered
is an attribute of JSF. It means that the component will not be rendered, therefore the component will not be part of the TreeView
that arms JSF behind the scenes, which means that the component can not be used to obtain its data or edit it. This can be checked simply by seeing the generated HTML, you will see that your component does not exist, as it does not exist, you can not apply any functionality via javascript or similar. That is why <a4j:ajax render="modelNameNew, prueba " event="change" execute="@this" />
fails.
disabled
is an HTML attribute. It means that the component is disabled or not. When sending the data of the form to the server, by default the data of the components that are disabled will not be sent to the server. However, these components are rendered and can be accessed via JavaScript. That's why <a4j:ajax render="modelNameNew, prueba " event="change" execute="@this" />
works correctly for this component.
The problem with using rendered
is very common when working with JSF. The solution is to use a UIContainer
on the component that has the attribute rendered
and re-render the UIContainer
instead of re-rendering the component in question. In code it is better understood:
<!-- Se indica que se renderizará pruebaContainer, no prueba -->
<a4j:ajax render="modelNameNew, pruebaContainer" event="change" execute="@this" />
<!--
Se crea un componente UIContainer que sirva como wrapper al componente a re-renderizar con el atributo rendered.
En este caso, utilizaré un h:panelGroup y le pondré el id pruebaContainer
-->
<h:panelGroup id="pruebaContainer">
<!-- Dentro del UIContainer colocamos el componente que necesita ser re-renderizado -->
<a4j:commandButton id="prueba" action="..." oncomplete="..." rendered="#{!managedBean.Boolean}" />
</h:panelGroup>