How To: Use FileUpload.setFileUploadListener(MethodBinding) with a MethodExpression
I have a problem with adding a FileUploadListener object to HtmlFileUpload (rich:fileupload) programmatically:
This works but is deprecated:
HtmlFileUpload upload = new HtmlFileUpload();
upload.setFileUploadListener(FacesContext.getCurrentInstance()
.getApplication().createMethodBinding(
"#{actions.storedObj开发者_Go百科ects["+this.getActionID()+"].uploadEventListener}",
new Class[] { UploadEvent.class }));
The Javadoc says that I should use MethodExpression instead but setFileUploadListener() will only accept FileUploadListener which is an instanceof MethodBinding but not MethodExpression. I'm using RichFaces 3.3.2 SR1.
Thanks in Advance!
Deprecation is not necessarily a technical problem. The code will still work. Deprecation is only a warning that the class/method in question is subject for future removal and that the API needs to be updated to reflect the changes. In this specific case, it is the RichFaces library which needs to be updated, not your code. Look around if this is already been mentioned/reported in the RichFaces issuetracker and if not, then report one, maybe they will put more hurry on it.
Expect from hacking the RichFaces source yourself, there is no way to get it to work with the improved MethodExpression
. Just live with it or add a @SuppressWarnings("deprecated")
line to the code.
精彩评论