This sample provides a Mendix backend module that facilitates server side operations that work with WebViewer
WebViewer provides a slick out-of-the-box responsive UI that enables you to view, annotate and manipulate PDFs and other document types inside any web project.
Click the button below to view the full project in GitHub.
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
10package webviewer.actions;
11
12import com.mendix.systemwideinterfaces.core.IContext;
13import com.mendix.webui.CustomJavaAction;
14import com.mendix.systemwideinterfaces.core.IMendixObject;
15
16public class GetFileId extends CustomJavaAction<java.lang.String>
17{
18 /** @deprecated use inputFile.getMendixObject() instead. */
19 @java.lang.Deprecated(forRemoval = true)
20 private final IMendixObject __inputFile;
21 private final webviewer.proxies.File inputFile;
22
23 public GetFileId(
24 IContext context,
25 IMendixObject _inputFile
26 )
27 {
28 super(context);
29 this.__inputFile = _inputFile;
30 this.inputFile = _inputFile == null ? null : webviewer.proxies.File.initialize(getContext(), _inputFile);
31 }
32
33 @java.lang.Override
34 public java.lang.String executeAction() throws Exception
35 {
36 // BEGIN USER CODE
37 return "" + this.inputFile.getMendixObject().getId().toLong();
38 // END USER CODE
39 }
40
41 /**
42 * Returns a string representation of this action
43 * @return a string representation of this action
44 */
45 @java.lang.Override
46 public java.lang.String toString()
47 {
48 return "GetFileId";
49 }
50
51 // BEGIN EXTRA CODE
52 // END EXTRA CODE
53}
54
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
10package webviewer.actions;
11
12import java.io.InputStream;
13import com.mendix.core.Core;
14import com.mendix.systemwideinterfaces.core.IContext;
15import com.mendix.systemwideinterfaces.core.IMendixIdentifier;
16import com.mendix.webui.CustomJavaAction;
17import com.mendix.systemwideinterfaces.core.IMendixObject;
18
19public class SaveDocument extends CustomJavaAction<java.lang.String>
20{
21 /** @deprecated use fileData.getMendixObject() instead. */
22 @java.lang.Deprecated(forRemoval = true)
23 private final IMendixObject __fileData;
24 private final webviewer.proxies.File fileData;
25
26 public SaveDocument(
27 IContext context,
28 IMendixObject _fileData
29 )
30 {
31 super(context);
32 this.__fileData = _fileData;
33 this.fileData = _fileData == null ? null : webviewer.proxies.File.initialize(getContext(), _fileData);
34 }
35
36 @java.lang.Override
37 public java.lang.String executeAction() throws Exception
38 {
39 // BEGIN USER CODE
40 // Get the file data we got from the request to write into the original object
41 InputStream stream = Core.getFileDocumentContent(getContext(), this.fileData.getMendixObject());
42 Core.storeFileDocumentContent(getContext(), __fileData, stream);
43 // Create the new file object
44 this.fileData.commit();
45
46 // With the file ID we got from the request, create an identifier object
47 IMendixIdentifier id = this.fileData.getMendixObject().getId();
48
49 return String.valueOf(id.toLong());
50 // END USER CODE
51 }
52
53 /**
54 * Returns a string representation of this action
55 * @return a string representation of this action
56 */
57 @java.lang.Override
58 public java.lang.String toString()
59 {
60 return "SaveDocument";
61 }
62
63 // BEGIN EXTRA CODE
64 // END EXTRA CODE
65}
66
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
10package webviewer.actions;
11
12import java.io.InputStream;
13import com.mendix.core.Core;
14import com.mendix.systemwideinterfaces.core.IContext;
15import com.mendix.systemwideinterfaces.core.IMendixIdentifier;
16import com.mendix.webui.CustomJavaAction;
17import webviewer.proxies.File;
18import com.mendix.systemwideinterfaces.core.IMendixObject;
19
20public class UpdateDocument extends CustomJavaAction<java.lang.Void>
21{
22 private final java.lang.String fileId;
23 /** @deprecated use Parameter.getMendixObject() instead. */
24 @java.lang.Deprecated(forRemoval = true)
25 private final IMendixObject __Parameter;
26 private final webviewer.proxies.File Parameter;
27
28 public UpdateDocument(
29 IContext context,
30 java.lang.String _fileId,
31 IMendixObject _parameter
32 )
33 {
34 super(context);
35 this.fileId = _fileId;
36 this.__Parameter = _parameter;
37 this.Parameter = _parameter == null ? null : webviewer.proxies.File.initialize(getContext(), _parameter);
38 }
39
40 @java.lang.Override
41 public java.lang.Void executeAction() throws Exception
42 {
43 // BEGIN USER CODE
44 // With the file ID we got from the request, create an identifier object
45 IMendixIdentifier id = Core.createMendixIdentifier(fileId);
46 // Load the original object from the context
47 File origFile = File.load(getContext(), id);
48 // Get the file data we got from the request to write into the original object
49 InputStream stream = Core.getFileDocumentContent(getContext(), this.Parameter.getMendixObject());
50 origFile.setContents(getContext(), stream, this.Parameter.getSize());
51 origFile.commit();
52 // Delete the new file object created when we sent the update request
53 this.Parameter.delete();
54 this.Parameter.commit();
55
56 return null;
57 // END USER CODE
58 }
59
60 /**
61 * Returns a string representation of this action
62 * @return a string representation of this action
63 */
64 @java.lang.Override
65 public java.lang.String toString()
66 {
67 return "UpdateDocument";
68 }
69
70 // BEGIN EXTRA CODE
71 // END EXTRA CODE
72}
73
Did you find this helpful?
Trial setup questions?
Ask experts on DiscordNeed other help?
Contact SupportPricing or product questions?
Contact Sales