loadAllRecords( ) on related form if head form is in find

I get the following exceptions if I cancel a find.:

This before I changed a code line for debugging.:

org.mozilla.javascript.WrappedException: Wrapped java.lang.ClassCastException: com.servoy.j2db.dataprocessing.Record cannot be cast to com.servoy.j2db.dataprocessing.FindState (H:\servoy_workspace_git\boss\svy_search\globals.js#85)

and this after I commented out a code line:

forms[ _triggerForm ].foundset.loadAllRecords( );

and commented it back in.:

org.mozilla.javascript.WrappedException: Wrapped java.lang.ClassCastException (H:\servoy_workspace_git\boss\svy_search\globals.js#85)

The error occurs in this line.:

forms[_form].controller.search( );

The error does not occur if I comment out.:

forms[ _triggerForm ].foundset.loadAllRecords( );

I think the problem occurs, because loadAllRecords is executed on a related form before controller.search on the head form is executed.

But it is correct to get an error message in this case? Also why I get another error message after I commented back in the line?

so you call loadAllrecords on a related from, and then you call search?

jcompagner:
so you call loadAllrecords on a related from, and then you call search?

Yes, but the search on the head form.

that doesn’t matter, you call loadAllRecords on a related foundset that is in find mode
Then you call search on the parent foundset

This is just bad order of calls/events. Why do you do that?

I am having a very similar problem with Servoy 7.4.10. This used to work in Servoy 6 in my onFind method:

	forms.ContractsMain.elements.ContractTabs.tabIndex = 2
	forms.ContractsInfo.controller.find()

Then after the user entered their criteria and hit enter:

forms.ContractsInfo.controller.search()

But does not in Servoy 7 – it says ‘record cannot be cast to’ like the above user. Or it spits into the console the below while providing a blank error to the user. If I turn off the change of tabs, it works if I am on the tab that shows Contracts Info. It does not otherwise.

Exception Object: java.lang.ClassCastException
MSG:
Wrapped java.lang.ClassCastException (C:\Users\meserow\servoy_workspace20171024\PRISM\globals.js#8023)

this is a very old issue and the problem was in the solution…
Because before doing search(), an loadAllRecords() was already triggered first on a relation that was also in find mode
Do then the search() is just confused.
What is the exact stack (full stacktrace) that you have?
Because i have no idea if it is really the same.

Hi Joan,
the error is:

Exception Object: java.lang.ClassCastException: com.servoy.j2db.dataprocessing.Record cannot be cast to com.servoy.j2db.dataprocessing.FindState

and the full stack trace of Ellen’s problem is:

com.servoy.j2db.dataprocessing.FindState.createFindStateJoins(FindState.java:670), com.servoy.j2db.dataprocessing.SQLGenerator.createConditionFromFindState(SQLGenerator.java:657), com.servoy.j2db.dataprocessing.SQLGenerator.getPKSelectSqlSelect(SQLGenerator.java:209), com.servoy.j2db.dataprocessing.FoundSet.getCurrentStateQuery(FoundSet.java:4731), com.servoy.j2db.dataprocessing.FoundSet.performFind(FoundSet.java:4781), com.servoy.j2db.dataprocessing.FoundSet.js_search(FoundSet.java:907), com.servoy.j2db.dataprocessing.FoundSet.search(FoundSet.java:862), sun.reflect.GeneratedMethodAccessor739.invoke(Unknown Source), sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source), java.lang.reflect.Method.invoke(Unknown Source), org.mozilla.javascript.MemberBox.invoke(MemberBox.java:158), org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:312), org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1774), org.mozilla.javascript.Interpreter.interpret(Interpreter.java:837), org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:158), org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:406), org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3204), org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:156), com.servoy.j2db.scripting.ScriptEngine.executeFunction(ScriptEngine.java:628), com.servoy.j2db.debug.RemoteDebugScriptEngine.executeFunction(RemoteDebugScriptEngine.java:393), com.servoy.j2db.BasicFormController.executeFunction(BasicFormController.java:824), com.servoy.j2db.BasicFormController.executeFormMethod(BasicFormController.java:708), com.servoy.j2db.BasicFormController.performFind(BasicFormController.java:1672), com.servoy.j2db.smart.cmd.CmdPerformFind.doIt(CmdPerformFind.java:77), com.servoy.j2db.smart.cmd.CmdManager$2.run(CmdManager.java:428), java.awt.event.InvocationEvent.dispatch(Unknown Source), java.awt.EventQueue.dispatchEventImpl(Unknown Source), java.awt.EventQueue.access$500(Unknown Source), java.awt.EventQueue$3.run(Unknown Source), java.awt.EventQueue$3.run(Unknown Source), java.security.AccessController.doPrivileged(Native Method), java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source), java.awt.EventQueue.dispatchEvent(Unknown Source), java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source), java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source), java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source), java.awt.EventDispatchThread.pumpEvents(Unknown Source), java.awt.EventDispatchThread.pumpEvents(Unknown Source), java.awt.EventDispatchThread.run(Unknown Source)

any Idea?

best regards

yes this is exactly the above scenario
where i already told there that somehow you do a load(All)Records() on a related foundset where the parent foundset is in find() mode.
That should not be done, that is a weird state,

If you go in find then don’t also try to load data through the related foundset of that parent find state.

If you have a (sample) solution where this happens we can have a look if you create a case for this.
Maybe we can test for this and ignore this relation completely, but i want to first see a valid use case.

Ok Joan, thank you for your answer.

marco.rossi:
Joan

Close, but it really needs an H.
His name is Johan ;)