I want to create a custom java action that parses a string on some delimiter and returns a List of the parsed values. I have an Invoice entity with an InvoiceID attribute.
My goal is to take a string of invoices like "44 55 66" and return the members of the SearchStringSplitResult entity with InvoiceID = 44, 55 or 66. Then I think I'll be able to create an association between SearchStringSplitRsult and Invoice that will allow me to return an Invoice list.
This is the code for my java action:
// This file was generated by Mendix Modeler.
//
// WARNING: Only the following code will be retained when actions are regenerated:
// - the import list
// - the code between BEGIN USER CODE and END USER CODE
// - the code between BEGIN EXTRA CODE and END EXTRA CODE
// Other code you write will be lost the next time you deploy the project.
// Special characters, e.g., é, ö, à , etc. are supported in comments.
package myfirstmodule.actions;
import com.mendix.systemwideinterfaces.core.IContext;
import com.mendix.webui.CustomJavaAction;
import com.mendix.systemwideinterfaces.core.IMendixObject;
import java.util.List;
import java.util.ArrayList;
public class SplitString extends CustomJavaAction<java.util.List<IMendixObject>>
{
private java.lang.String StringToSplit;
private java.util.List<IMendixObject> __SearchStringSplitResultList;
private java.util.List<myfirstmodule.proxies.SearchStringSplitResult> SearchStringSplitResultList;
public SplitString(IContext context, java.lang.String StringToSplit, java.util.List<IMendixObject> SearchStringSplitResultList)
{
super(context);
this.StringToSplit = StringToSplit;
this.__SearchStringSplitResultList = SearchStringSplitResultList;
}
@Override
public java.util.List<IMendixObject> executeAction() throws Exception
{
this.SearchStringSplitResultList = new java.util.ArrayList<myfirstmodule.proxies.SearchStringSplitResult>();
if (__SearchStringSplitResultList != null)
for (IMendixObject __SearchStringSplitResultListElement : __SearchStringSplitResultList)
this.SearchStringSplitResultList.add(myfirstmodule.proxies.SearchStringSplitResult.initialize(getContext(), __SearchStringSplitResultListElement));
// BEGIN USER CODE
String[] splitArray = StringToSplit.split("");
for (String splitStringElement : splitString){
List<myfirstmodule.proxies.SearchStringSplitResult> ResultList = new ArrayList<myfirstmodule.proxies.SearchStringSplitResult>();
}
// END USER CODE
}
/**
* Returns a string representation of this action
*/
@Override
public java.lang.String toString()
{
return "SplitString";
}
// BEGIN EXTRA CODE
// END EXTRA CODE
}