How to get index of object in its list (java)? - Mendix Forum

How to get index of object in its list (java)?

0

Hi guys

 

I simply want the index of an object in its list, so I would expect that the following code (lastIndexOf or indexOf) should work:


		// BEGIN USER CODE
		int i1= ObjectList.lastIndexOf(CurrentObject);

but I always get -1 (not found in the list, for both methods). While the objectID is definitely in the objectList.

So what do I wrong, did i miss something how to get it work in Java?

EDIT 1: when looping through the given list and looking for the iterated object, it finds the index...so probably it has to do with the parameter object?

		for (IMendixObject __ObjElement  : __ObjList) {
			int i1= __ObjList.lastIndexOf(__ObjListElement);
			Core.getLogger("obj").warn("index: " + i1);
		}
		
		for (Obj ObjListElement  : ObjList) {
			int i1= ObjList.lastIndexOf(ObjListElement);
			Core.getLogger("obj").warn("index: " + i1);
		}

 

asked
1 answers
1

Maybe you should do a .GetMendixObject() on the CurrentObject object.

answered