Dynamic Xpath using JavaAction- using Xpath.create().
0
Hi, I’m trying to work on multi select filter functionality along with pagination, where I need to retrieve the data every time from database. For this, I have came across Xpath.create() in java action to create dynamic xpath. But the problem, I need to create an xpath using list and not with single string or object(Eg. Retrieve employees where city = ‘city1’ or city = ‘city2’ or city = ‘city3’ and department = ‘IT’ or department = ‘Functional’ or department = ‘Network’ ). I’m using the below code to retrieve using single attribute match. public java.util.List<IMendixObject> executeAction() throws Exception { this.States = new java.util.ArrayList<risk.proxies.State>(); if (__States != null) for (IMendixObject __StatesElement : __States) this.States.add(risk.proxies.State.initialize(getContext(), __StatesElement)); // BEGIN USER CODE XPath<DC_Inventory> xpath = XPath.create(getContext(), DC_Inventory.class) .subconstraint( DC_Inventory.MemberNames.DC_Inventory_State , State.entityName ) .eq( State.MemberNames.Name , this.StateVal ) .close() .addSortingAsc(DC_Inventory.MemberNames.ReportingMolecule); List<IMendixObject> DCInventorData = xpath.allMendixObjects(); return DCInventorData; //throw new com.mendix.systemwideinterfaces.MendixRuntimeException("Java action was not implemented"); // END USER CODE } Can we do this using list of objects..?
asked
Laxman Mylapilli
1 answers
0
Hi Laxman,
Why not iterate over your list of objects and retrieve the results per object via your java action. Create a list to return beforehand, and in the iterator add the retrieved objects to your list with UNION to get a list of unique results.
I think this would perform better as well instead of an unknown number of OR statements.