I am facing a problem that I could not find any resolution for…
I have a selectManyChoice component like this:
<af:selectManyChoice value="#{bindings.my_VO1.inputValue}"
label="myLabel" id="smc1"
binding="#{pageFlowScope.myBean.myMultiSelection}"
autoSubmit="true">
<f:selectedItems value="#{bindings.my_VO1.items}" id="si1"/>
</af:selectManyChoice>
For getting out the values, I tested using 2 buttons like this:
<af:commandButton text="First Button"
id="cb1"
action="#{pageFlowScope.myBean.saveSelection}>
<af:fileDownloadActionListener method="#{pageFlowScope.myBean.exportReport}"/>
</af:commandButton>
And:
<af:commandButton text="Second Button"
id="cb2"
action="#{pageFlowScope.myBean.saveSelection}/>
The second button could successfully get the selected values and print them out to the screen. However, the first button could not. It would always throw a NullPointerException when i tried to call myMultiSelection.getValue(), at this line of code:
public String saveSelection() {
if (myMultiSelection.getValue() != null) {
The only difference between them is the fileDownloadActionListener tag. I wonder if that tag was affecting the inner works of the first button…However, I still need that tag, since the purpose of the button is to generate a pdf file based on the selected values, and have the browser download that file. Can anybody point me to the right direction?
You can try it this way :
Use your second button and in his actionlistener you just call the fileDownloadActionListener. That way you know for sure if the selected value is correct.
Example : http://adfwithejb.blogspot.be/2012/08/calling-affiledownloadactionlistener_2.html
Edit:
Instead of using JS to call the actionlistener you can do it this way:
Add these to your page :
Then in your bean, go to the saveSelection method and do some stuff the get your correct data.
After that add this :
This will trigger the hidden button without pressing it. (make sure you have a binding of course)