I'm trying to download a file by clicking on a button. I have a checkbox that when checked it puts some filters on that file. The problem is that everytime the checkbox value is false even though is checked
I tried using ajax renderer="" without success. Maybe I called it badly.
menu.xhtml (just the part where the form is)
<div id="mainTools" style="position: relative;bottom: 0;">
<h:form id="form1">
<div>
<p:selectBooleanCheckbox style="padding-left:18px"
value="#{fileDownloadBean.filteringRequired}">
<p:ajax update=":notifications:msgs"
render=":form2"
/>
</p:selectBooleanCheckbox>
<h:outputText value="Filtering" style="padding-left:4px"/>
</div>
</form>
<div id="secondTools">
<h:form id="form2">
<h:panelGrid columns="1" style="margin-left:10px;" cellpadding="5">
<p:commandButton value="Download" style="width:170px;">
<p:fileDownload value="#{downloadFile.getFile()}">
</p:fileDownload>
</p:commandButton>
</h:panelGrid>
</h:form>
</div>
</div>
filedownload.java
if(filteringRequired){
//do something
}
else{
//do other
}
I need to know how to store the checkbox value (true/false) and use it in the form where the button is (the ajax doesn't work) because after checking the "filtering" checkbox I press the "Download button" and in the java file, when running debug, it enters on the else branch. The "isFilteringRequired" is always false.