How to use FileUpload.setFileUploadListener (MethodBinding) with Expression method
I am having problem adding FileUploadListener object to HtmlFileUpload (rich: fileupload) programmatically:
This works, but is deprecated:
HtmlFileUpload upload = new HtmlFileUpload();
upload.setFileUploadListener(FacesContext.getCurrentInstance()
.getApplication().createMethodBinding(
"#{actions.storedObjects["+this.getActionID()+"].uploadEventListener}",
new Class[] { UploadEvent.class }));
Javadoc says I should use MethodExpression, but setFileUploadListener () will only accept FileUploadListener, which is an instance of MethodBinding, but not MethodExpression. I am using RichFaces 3.3.2 SR1.
Thank you Advance!
a source to share
Fatigue is not necessarily a technical problem. The code will work. Rejection is only a warning that the class / method in question is subject to future deletion and that the API needs to be updated to reflect the changes. In this particular case, the RichFaces library needs to be updated, not your code. Look around if this has already been mentioned / reported on the Richfaces issuetracker , and if not, please report it, maybe they will rush to it.
Expect to hack the RichFaces source yourself, there is no way to make it work with an improved one MethodExpression
. Just live with it or add a line @SuppressWarnings("deprecated")
to your code.
a source to share