Show list without defining the view

0
Hi, following scenario: The user is able to select an entity, attribute, operator and an treshold on the user interface. For this I am using the MxModelReflection module. With that information a microflow starts and calls a java action. This java action retrieves a list based on the input of the user by using xpath. This result list should be saved and shown to the user. The way I want to solve this: Everything works until I want to save/show the list. After retrieving the list via java-action my idea is to parse the list as string-variable in JSON-format. Afterwards I want to use plot.ly to show the json-string in a table format. However I am struggling with parsing the list in to a string/json-format.  My question: Is there any way to quickly parse the result list (where I don’t know the entity beforehand) to a json-structure/string, so that I can use plot.ly to show the result? Otherwise is there a better approach for this? Best regards, Ömer
asked
2 answers
0

Hi Omer,

You can create a json structure an export mapping for this structure and then utilize the export mapping activity to generate your json string. If you have a list, for the export mapping to work, I believe you will need to associate that list to a single object with a many to 1 relationship. 

 

Here is some documentation on export mappings. 

https://docs.mendix.com/refguide/export-mappings

 

Hope this helps!

answered
0

Just thinking out aloud here. In your Java you have the list of MxObjects. Could you not use the Jackson library to convert the Mendix object to a JSON object ( https://blog.codota.com/how-to-convert-a-java-object-into-a-json-string/ ) based on the model reflection? Because from each Mendix object you have the attribute name and type and thus create a generic JSON object according through this.
Another sollutions would be that based on the entity you know what list the Java action returns and based on that call another microflow that does the mapping. But this would only work if the number of entities is not that big.
Regards,

Ronald

 

answered