问题
Is there anyway to get the a File upload/download to work in a extension library dialog box? The file unload control seems to work but never stores the file in the document. The other controls(inputtext, computed and dates) in the dialog works correctly Thx
回答1:
I don't have code to give you YET... but in the day job we use PLUpload instead of the built in controls. You can out PLUload inside a standard XPages dialog box. It gets connected to an XAgent of which this snippet:
http://openntf.org/XSnippets.nsf/snippet.xsp?id=custom-xpage-file-upload-handler
is probably what you're looking for. I'm currently using an SSJS version but will be looking to migrate to the Java one.
I then have code to process the uploads and move them to another database and also resize jpg's and stuff.
A full example will be presented at the MWLug (2014) user group meeting and will also come to NotesIn9 soon. I just don't have all the code samples ready yet. But PLUpload with that snippet should be a good start.
回答2:
What's your Domino server version? If it's lower than 9.0.1 file uploads cannot be done via a partial refresh, so it's not possible. In 9.0.1 you can run file upload with partial refresh, so it might be feasible.
回答3:
It's possible.
The following code will work on a 9.0.1 server. Not sure about pre-9.0.1 though: doing a partial refresh with a file upload is a feature that was introduced in 9.0.1. A tip: if you include validations in the dialog, a partial refresh of only the dialog won't work: you need to refresh an element that contains the dialog.
<xp:text
escape="true"
id="computedField1"
value="#{javascript:@Now().getTime()}">
</xp:text>
<xp:button
value="show dialog"
id="button1">
<xp:eventHandler
event="onclick"
submit="true"
refreshMode="partial"
refreshId="dialog1">
<xp:this.action><![CDATA[#{javascript:getComponent("dialog1").show();}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
<xe:dialog
id="dialog1"
title="Look. I'm a dialog!">
<xp:panel>
<xp:this.data>
<xp:dominoDocument
var="document1"
formName="fUpload">
</xp:dominoDocument>
</xp:this.data>
<xe:dialogContent
id="dialogContent1">
Pick a file:
<xp:fileUpload
id="fileUpload1"
value="#{document1.files}"></xp:fileUpload>
</xe:dialogContent>
<xe:dialogButtonBar
id="dialogButtonBar1">
<xp:button
value="Save"
id="button2">
<xp:eventHandler
event="onclick"
submit="true"
refreshMode="partial"
refreshId="dialog1"
immediate="false"
save="true"></xp:eventHandler>
</xp:button>
</xe:dialogButtonBar>
</xp:panel>
</xe:dialog>
来源:https://stackoverflow.com/questions/24616861/file-upload-in-a-xpages-extension-library-dialog-box