The commandlink link2 does not have work after an ajax call is made to render a panel group panel1. This was working when the whole page was relaoded instead of ajax call to display the modal.
Main.xhtml
<h:panelGroup id="panel1">
<ui:fragment rendered="#{downloadTo.showModal}">
<ui:include src="modal.xhtml" />
</ui:fragment>
</h:panelGroup>
<h:form>
<h:commandLink id="link" value="download" action="#{backing.openModal()}">
<f:ajax render="_panel1"/>
</h:commandLink>
</h:form>
modal.xhtml contains
<h:form>
<h:commandLink id="link2" value="download" action="#{backing.downloadData()}"/>
</h:form>
You need to make sure that the backing bean holding the condition for the
renderedattribute is@ViewScoped. Otherwise the condition will be reinitialized to default on the ajax request. You also need to change the<f:ajax>render to explicitly include the client ID of any other<h:form>which is to be ajax-updated, otherwise it will lose its view state.E.g. in
modal.xhtmlwith this change in
main.xhtmlSee also: