Parse String with Java action

1
Hi, I want to pass in a string and have it return a list of strings ... could you help me write the corresponding Java code Here is the INCORRECT version I have so far .. not sure how to actually set the IMendixObject value (to set the string values): String delims = "[ ]"; String[] tokens = StringToParse.split(delims); List<IMendixObject> parsedString = null; IMendixObject str = null; for (int i = 0; i < tokens.length; i++) { str.setValue(this.getContext(), "parsedText", tokens[i]); parsedString.add(str); } return parsedString;
asked
1 answers
2

I'm assuming you want to create a list of x new IMendixObjects and return that. You can use the proxies that were generated in your project to accomplish this.

For instance, if you would want to create Administration.Account objects and store all the strings in the usernames, the code would be something like this:

    String delims = "[ ]";
    String[] tokens = StringToParse.split(delims);
    List<Account> accountList = new ArrayList<Account>();

    for (int i = 0; i < tokens.length; i++) {

        Account account = Account.create(getContext());
        account.setName(tokens[i]);
        accountList.add(account);
   }

   return accountList;
answered