The problem is, when I set the render attribute of f:ajax to @form the btnCreateCSV render correctly. But, if I change it to the id of button nothing happen. I wonder to know, how can I solve this problem.
This is my xhtml code :
<h:panelGrid layout="block">
<h:commandButton value="View SQL" action="#{sparqlQueryBean.convert}" id="btnViewSql">
<f:ajax execute="txtQuery btnCreateCSV" render="btnCreateCSV txtSqlQuery" onevent="waiting" listener="#{sparqlQueryBean.generateCommands}"></f:ajax>
</h:commandButton>
<h:commandButton value = "CSV" action = "#{sparqlQueryBean.createCSV}" id = "btnCreateCSV" rendered="#{sparqlQueryBean.showCSV == true}">
<f:ajax execute="@none" render = "@none" onevent="waiting"></f:ajax>
</h:commandButton>
And it’s my bean class. In generateCommands method, the value of showCSV set to true. But it dosn’t work.
public void generateCommands (AjaxBehaviorEvent event) {
this.setShowCSV(true);
}
With
<f:ajax>, JavaScript is used to locate elements in the HTML DOM tree and re-render them. But if a JSF component is not rendered into the HTML output, then there’s also nothing in the HTML DOM tree to re-render. You should either re-render its closest parent component which is always rendered instead, or wrap it in another component (e.g.<h:panelGroup>) which is always rendered and re-render it instead.See also: