Steven,
Split the string with:
str = "44 66 55";
String[] splitArray = str.split("\\s+");
Then loop over the splitArray and create the entities. The code assumes a space to be the delimiter, but this can be any character just change the regex in the split function.
Optionally add the entities you create in the loop to an ArrayList<IMendixObject> and return this list.
[Edit]
To get the list of objects use the code below adapt this to match your entity names:
package myfirstmodule.actions;
import java.util.ArrayList;
import myfirstmodule.proxies.testsplitresult;
import com.mendix.core.Core;
import com.mendix.systemwideinterfaces.core.IContext;
import com.mendix.webui.CustomJavaAction;
import com.mendix.systemwideinterfaces.core.IMendixObject;
public class Java_action extends CustomJavaAction<java.util.List<IMendixObject>>
{
private String StringToSplit;
public Java_action(IContext context, String StringToSplit)
{
super(context);
this.StringToSplit = StringToSplit;
}
@Override
public java.util.List<IMendixObject> executeAction() throws Exception
{
// BEGIN USER CODE
String[] splitArray = StringToSplit.split(" ");
ArrayList<IMendixObject> resultList = new ArrayList<IMendixObject>();
for (String ValueStr : splitArray) {
IMendixObject myEntity = Core.instantiate(getContext(), testsplitresult.entityName.toString());
myEntity.setValue(getContext(), testsplitresult.MemberNames.SearchAttribute.toString(), ValueStr);
resultList.add( myEntity);
}
return resultList;
// END USER CODE
}
/**
* Returns a string representation of this action
*/
@Override
public String toString()
{
return "Java_action";
}
// BEGIN EXTRA CODE
// END EXTRA CODE
}
The action in the modeler is a little bit different than you posted:
Hope this will solve your issue.
To add on to Erwin's answer: I'm guessing you're trying to retrieve objects of the invoice entity that already exist.
If that's the case, here's some code that should get you close:
str = "44 66 55";
String[] splitArray = str.split("\\s+");
String xpathQuery = "//MyModule.Invoice[";
for(int i =0; i < splitArray.length; i++) {
xpathQuery += "InvoiceID = " + splitArray[i];
if (i < splitArray.length) {
xpathQuery += " or ";
}
}
xpathQuery += "]";
return core.retrieveXPathQuery(getContext(), xpathQuery);
Note I wrote this without syntax checking and I haven't tested it. Hopefully it at least demostrates the concept. Use this reference for the call to retrieveXPathQuery.