I have a use-case where in I want to invoke a fileDownloadActionListener tied to a commandButton programmatically. I DO NOT want to invoke it at the jspx level. Basically I want to conditionally invoke the fileDownloadActionListener. If a method returns true then I invoke it else I don't. If I have the fileDownloadActionListener at the jspx level, the moment the commandButton invoking this is clicked, it would fire the pop-up immediately but I want to perform a validation before firing it.
This is not as simple as it looks. The fileDownloadActionListener
is a client behavior tag, so you can't just queue an action on the button. You must call a JavaScript method which does this for you.
I blogged this solution here.