|
| 1 | +// This file was generated by Mendix Studio Pro. |
| 2 | +// |
| 3 | +// WARNING: Only the following code will be retained when actions are regenerated: |
| 4 | +// - the import list |
| 5 | +// - the code between BEGIN USER CODE and END USER CODE |
| 6 | +// - the code between BEGIN EXTRA CODE and END EXTRA CODE |
| 7 | +// Other code you write will be lost the next time you deploy the project. |
| 8 | +// Special characters, e.g., é, ö, à, etc. are supported in comments. |
| 9 | + |
| 10 | +package webviewer.actions; |
| 11 | + |
| 12 | +import java.io.InputStream; |
| 13 | +import com.mendix.core.Core; |
| 14 | +import com.mendix.systemwideinterfaces.core.IContext; |
| 15 | +import com.mendix.systemwideinterfaces.core.IMendixIdentifier; |
| 16 | +import com.mendix.webui.CustomJavaAction; |
| 17 | +import com.mendix.systemwideinterfaces.core.IMendixObject; |
| 18 | + |
| 19 | +public class SaveDocument extends CustomJavaAction<java.lang.String> |
| 20 | +{ |
| 21 | + private IMendixObject __fileData; |
| 22 | + private webviewer.proxies.File fileData; |
| 23 | + |
| 24 | + public SaveDocument(IContext context, IMendixObject fileData) |
| 25 | + { |
| 26 | + super(context); |
| 27 | + this.__fileData = fileData; |
| 28 | + } |
| 29 | + |
| 30 | + @java.lang.Override |
| 31 | + public java.lang.String executeAction() throws Exception |
| 32 | + { |
| 33 | + this.fileData = this.__fileData == null ? null : webviewer.proxies.File.initialize(getContext(), __fileData); |
| 34 | + |
| 35 | + // BEGIN USER CODE |
| 36 | + // Get the file data we got from the request to write into the original object |
| 37 | + InputStream stream = Core.getFileDocumentContent(getContext(), this.fileData.getMendixObject()); |
| 38 | + Core.storeFileDocumentContent(getContext(), __fileData, stream); |
| 39 | + // Create the new file object |
| 40 | + this.fileData.commit(); |
| 41 | + |
| 42 | + // With the file ID we got from the request, create an identifier object |
| 43 | + IMendixIdentifier id = this.fileData.getMendixObject().getId(); |
| 44 | + |
| 45 | + return id.toString(); |
| 46 | + // END USER CODE |
| 47 | + } |
| 48 | + |
| 49 | + /** |
| 50 | + * Returns a string representation of this action |
| 51 | + * @return a string representation of this action |
| 52 | + */ |
| 53 | + @java.lang.Override |
| 54 | + public java.lang.String toString() |
| 55 | + { |
| 56 | + return "SaveDocument"; |
| 57 | + } |
| 58 | + |
| 59 | + // BEGIN EXTRA CODE |
| 60 | + // END EXTRA CODE |
| 61 | +} |
0 commit comments