Requirement is to render a component outside the form after an ajax call. I have tried with the following code but the text was not being rendered.
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ads="http://java.sun.com/jsf/composite/components">
<ui:include src="secondfile"/>
<h:panelGroup id="panel1" rendered="#{bean.access}">
Some text
</h:panelGroup>
</ui:composition>
Secondfile:
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ads="http://java.sun.com/jsf/composite/components">
<f:ajax render="@form _panel1">
<h:selectOneRadio id="access" value="#{beanTO.access}">
<f:selectItem itemValue="true" itemLabel="yes"/>
<f:selectItem itemValue="true" itemLabel="yes"/>
</h:selectOneRadio>
</f:ajax>
</ui:composition>
I assume that you’ve changed the default naming container separator character from
:to_, otherwise you should have used:panel1instead of_panel1)You’re trying to ajax-render a component which is by itself conditionally rendered by the server side. This will not work when the component is not rendered in first place. JS won’t be able to locate the desired HTML element to update after the ajax response arrives. You need to wrap it in another component which is always rendered to the HTML output and set the
renderedcondition on the wrapped component.See also: