SOLVED: How to prevent file dialog on XPage upload control

  • I have an upload control on a XPage that may or may not contain a file already. If it contains a file I want to pop a confirm for replacement, and cancel the file dialog if the user clicks No. Typically one does this by returning false from the JS onClick, far as I know, but if I do that on the onClick for the upload control it ignores me and pops the file dialog anyway.

  • Ahhh. It’s the Events tab biting me the posterior again. I don’t know why I keep drinking that kool-aid. Here’s what it generates when adding a client script action:

<xp:fileUpload value=“#{DFile.File}” rendered=“#{javascript:DFile.isEditable()}”>

<xp:eventHandler event="onclick" submit="false">

	<xp:this.script><![CDATA[

alert(“This action will replace the existing file.”); return false;

	]]></xp:this.script>

</xp:eventHandler>

</xp:fileUpload>

Here’s what works, created by editing the onclick property directly:

<xp:fileUpload value=“#{DFile.File}” rendered=“#{javascript:DFile.isEditable()}”>

<xp:this.onclick><![CDATA[

alert(“This action will replace the existing file.”); return false;

]]></xp:this.onclick>

</xp:fileUpload>

  • This must be what Lotus calls “honey”.

Hope this helps someone else…

Subject: Thanks - this is exactly what I needed!

Thank you! I had this same problem, and the solution worked perfectly.