Hi All,
I am trying to build a java module for ignition and have run into an issue. I would like to send back data to populate a drop down which is an array of objects [{‘value’:‘example’,‘label’:example},{…},…]. Right now I have it working but inside a script I am forced to write:
import ast
self.props.options = []
for category in system.meslite.pdefm.materialcategory.getMaterialCategoriesParentDropdown():
self.props.options.append(ast.literal_eval(str(vars(category))))
My question what is the data type I need to return in my java code to simply write in the script.
self.props.options = system.meslite.pdefm.materialcategory.getMaterialCategoriesParentDropdown()
Java Code
@Override
protected Dict[] getMaterialCategoriesParentDropdownImpl() throws ApiException {
List<MaterialCategoryDto> materialCategoryDtos = api.getAllMaterialCategories();
int listSize = materialCategoryDtos.size();
Dict[] materialCategories = new Dict[listSize];
for (int i = 0; i<listSize; i++){
Dict category = new Dict();
category.__setattr__(Py.newString("value"),
Py.newString(Objects.requireNonNull(materialCategoryDtos.get(i).getUid()).toString()));
category.__setattr__(Py.newString("label"),Py.newString(
Objects.requireNonNull(materialCategoryDtos.get(i).getCategoryName())));
materialCategories[i] = category;
}
return materialCategories;
}