Reputation: 845
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>
Upvotes: 2
Views: 6211
Reputation: 1109865
You need to make sure that the backing bean holding the condition for the rendered
attribute 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.xhtml
<h:form id="downloadForm">
<h:commandLink id="link2" value="download" action="#{backing.downloadData()}"/>
</h:form>
with this change in main.xhtml
<h:form>
<h:commandLink id="link" value="download" action="#{backing.openModal()}">
<f:ajax render="_panel1 _downloadForm" />
</h:commandLink>
</h:form>
Upvotes: 2
Reputation: 3509
what i see is, that you are rendering _panel1
not panel1
. this should work:
<h:commandLink id="link" value="download" action="#{backing.openModal()}">
<f:ajax render="panel1"/>
</h:commandLink>
Upvotes: 0