title: Override the upload function of a file upload control
body: <p>I want to override the upload function of a file upload control in order to add the functionality that I need. I am trying to adapt the code from the following link to my case</p>
  
  <p><a href="https://stackoverflow.com/questions/13101615/auto-save-doc-after-delete-of-attachment-in-file-download-control">Auto-save doc after delete of attachment in File Download control?</a></p>
  
  <p>by changing the type of the second parameter to <em>com.ibm.xsp.component.xp.XSPFileUpload</em>, i.e.:</p>
  
  <pre><code>function rekOverrideFileDownloadAction( component:javax.faces.component.UIOutput,  fDownload:com.ibm.xsp.component.xp.XSPFileUpload ){
  </code></pre>
  
  <p>and the code in the MethodBinding mBinding and by using the name of my file upload control, i.e.:</p>
  
  <pre><code> var mBinding = facesContext.getApplication().createMethodBinding("#{javascript:print('Uploaded');}", null );
  overrideFileDownloadAction( getComponent( 'fileUpload1' ) );
  </code></pre>
  
  <p>Unfortunately, a javax.faces.FacesException occurs.</p>
  
  <p>Can anyone help me to modify this code in order to just print this message when the user uploads a file?</p>
  
  <p>Stack Trace:</p>
  
  <pre><code>javax.faces.FacesException
  javax.faces.FacesException.&lt;init&gt;(FacesException.java:97)
  com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:86)
  com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:210)
  com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:96)
  com.ibm.xsp.controller.FacesControllerImpl.execute(FacesControllerImpl.java:250)
  com.ibm.xsp.webapp.FacesServlet.serviceView(FacesServlet.java:209)
  com.ibm.xsp.webapp.FacesServletEx.serviceView(FacesServletEx.java:204)
  com.ibm.xsp.webapp.FacesServlet.service(FacesServlet.java:160)
  com.ibm.xsp.webapp.FacesServletEx.service(FacesServletEx.java:138)
  com.ibm.xsp.webapp.DesignerFacesServlet.service(DesignerFacesServlet.java:103)
  com.ibm.designer.runtime.domino.adapter.ComponentModule.invokeServlet(ComponentModule.java:576)
  com.ibm.domino.xsp.module.nsf.NSFComponentModule.invokeServlet(NSFComponentModule.java:1281)
  com.ibm.designer.runtime.domino.adapter.ComponentModule$AdapterInvoker.invokeServlet(ComponentModule.java:847)
  com.ibm.designer.runtime.domino.adapter.ComponentModule$ServletInvoker.doService(ComponentModule.java:796)
  com.ibm.designer.runtime.domino.adapter.ComponentModule.doService(ComponentModule.java:565)
  com.ibm.domino.xsp.module.nsf.NSFComponentModule.doService(NSFComponentModule.java:1265)
  com.ibm.domino.xsp.module.nsf.NSFService.doServiceInternal(NSFService.java:653)
  com.ibm.domino.xsp.module.nsf.NSFService.doService(NSFService.java:476)
  com.ibm.designer.runtime.domino.adapter.LCDEnvironment.doService(LCDEnvironment.java:341)
  com.ibm.designer.runtime.domino.adapter.LCDEnvironment.service(LCDEnvironment.java:297)
  com.ibm.domino.xsp.bridge.http.engine.XspCmdManager.service(XspCmdManager.java:272)
  
  java.lang.NullPointerException
  com.ibm.xsp.actions.ActionGroup.invoke(ActionGroup.java:135)
  com.ibm.xsp.actions.ActionGroup.invoke(ActionGroup.java:135)
  com.ibm.xsp.application.ActionListenerImpl.processAction(ActionListenerImpl.java:60)
  javax.faces.component.UICommand.broadcast(UICommand.java:324)
  com.ibm.xsp.component.UIEventHandler.broadcast(UIEventHandler.java:366)
  com.ibm.xsp.component.UIViewRootEx.broadcast(UIViewRootEx.java:1535)
  javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:307)
  javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:428)
  com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:94)
  com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:210)
  com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:96)
  com.ibm.xsp.controller.FacesControllerImpl.execute(FacesControllerImpl.java:250)
  com.ibm.xsp.webapp.FacesServlet.serviceView(FacesServlet.java:209)
  com.ibm.xsp.webapp.FacesServletEx.serviceView(FacesServletEx.java:204)
  com.ibm.xsp.webapp.FacesServlet.service(FacesServlet.java:160)
  com.ibm.xsp.webapp.FacesServletEx.service(FacesServletEx.java:138)
  com.ibm.xsp.webapp.DesignerFacesServlet.service(DesignerFacesServlet.java:103)
  com.ibm.designer.runtime.domino.adapter.ComponentModule.invokeServlet(ComponentModule.java:576)
  com.ibm.domino.xsp.module.nsf.NSFComponentModule.invokeServlet(NSFComponentModule.java:1281)
  com.ibm.designer.runtime.domino.adapter.ComponentModule$AdapterInvoker.invokeServlet(ComponentModule.java:847)
  com.ibm.designer.runtime.domino.adapter.ComponentModule$ServletInvoker.doService(ComponentModule.java:796)
  com.ibm.designer.runtime.domino.adapter.ComponentModule.doService(ComponentModule.java:565)
  com.ibm.domino.xsp.module.nsf.NSFComponentModule.doService(NSFComponentModule.java:1265)
  com.ibm.domino.xsp.module.nsf.NSFService.doServiceInternal(NSFService.java:653)
  com.ibm.domino.xsp.module.nsf.NSFService.doService(NSFService.java:476)
  com.ibm.designer.runtime.domino.adapter.LCDEnvironment.doService(LCDEnvironment.java:341)
  com.ibm.designer.runtime.domino.adapter.LCDEnvironment.service(LCDEnvironment.java:297)
  com.ibm.domino.xsp.bridge.http.engine.XspCmdManager.service(XspCmdManager.java:272)
  </code></pre>
  
  <p>I also noticed that if I add a script to an event, e.g. onChange, so that an event handler is created no exception occurs. So I think the exception is thrown because there is no event handler and that leads to a null pointer. For now I have added the functionality I need to the onChange event and it is ok, but it would be nice if someone could tell me if there is a way to override it.</p>
  
  <p>Thank you in advance!</p>