--Environment - CentOS Linux release 7.8.2003 (Core) - Eclipse IDE for Enterprise Java Developers.Version: 2020-03 (4.15.0) - openjdk version "11.0.7" 2020-04-14 LTS - JSF 2.3.9
Eclipse console log
javax.el.MethodNotFoundException: /base.xhtml @17,113 listener="#{uploadBean.uploadFile}": Method not found: class brans.UploadBean.uploadFile(javax.faces.event.AjaxBehaviorEvent)
at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:69)
at com.sun.faces.facelets.tag.jsf.core.AjaxBehaviorListenerImpl.processAjaxBehavior(AjaxHandler.java:403)
at javax.faces.event.AjaxBehaviorEvent.processListener(AjaxBehaviorEvent.java:100)
at javax.faces.component.behavior.BehaviorBase.broadcast(BehaviorBase.java:82)
at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:481)
at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:847)
at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1395)
at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:58)
at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:76)
at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:177)
at javax.faces.webapp.FacesServlet.executeLifecyle(FacesServlet.java:707)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:451)
...abridgement...
UploadBean.java
...abridgement...
public void uploadFile(FacesContext fc, UIComponent uic, Object value) throws IOException {
if (!isUpload()) {
...abridgement...
base.xhtml
...abridgement...
<f:ajax event="change" execute="uploadArea" render="uploadArea" listener="#{uploadBean.uploadFile}" />
...abridgement...
"Method parameters are different" = "Different method" = "There is no method specified in the listener attribute" When I tried various things ... inadvertently ... when I thought about it, it was natural, but it turned out to be "uh?"
UploadBean.java
public void uploadFile() throws IOException {
//Or
public void uploadFile(AjaxBehaviorEvent event) throws IOException {
If you receive javax.faces.event.AjaxBehaviorEvent, you can get the Faces context with getFacesContext
.
AjaxBehaviorEvent represents the behavior of Ajax-specific components). AjaxBehaviorEvent (Jakarta EE 8 Specification API) --Javadoc Japanese translation
base.xhtml
<f:ajax event="change" execute="uploadArea" render="uploadArea" listener="#{uploadBean.uploadFile(hoge, fuga, value)}" />
Recommended Posts