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

Discuss all problems you have with Servoy here. It might help to mention the Servoy version and Operating System version you are using

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

Postby deezzub » Thu Sep 18, 2014 1:54 pm

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:

Code: Select all
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.:

Code: Select all
forms[_form].controller.search( );


The error does not occur if I comment out.:

Code: Select all
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?
deezzub
 
Posts: 328
Joined: Tue May 28, 2013 3:02 pm
Location: Oldenburg, Germany

Re: loadAllRecords( ) on related form if head form is in fin

Postby jcompagner » Thu Oct 23, 2014 12:53 pm

so you call loadAllrecords on a related from, and then you call search?
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8829
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: loadAllRecords( ) on related form if head form is in fin

Postby deezzub » Thu Oct 23, 2014 2:50 pm

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


Yes, but the search on the head form.
deezzub
 
Posts: 328
Joined: Tue May 28, 2013 3:02 pm
Location: Oldenburg, Germany

Re: loadAllRecords( ) on related form if head form is in fin

Postby jcompagner » Fri Oct 24, 2014 11:56 am

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?
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8829
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: loadAllRecords( ) on related form if head form is in fin

Postby ellenmeserow » Tue Nov 28, 2017 7:45 pm

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

Code: Select all
   forms.ContractsMain.elements.ContractTabs.tabIndex = 2
   forms.ContractsInfo.controller.find()


Then after the user entered their criteria and hit enter:

Code: Select all
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)
ellen escarcega (formerly meserow)
meserow design
Servoy 2019 9
MSSQL 2017
Windows AWS Servers
ellenmeserow
 
Posts: 366
Joined: Sat Aug 07, 2004 10:18 pm
Location: Seattle, WA USA

Re: loadAllRecords( ) on related form if head form is in fin

Postby jcompagner » Wed Nov 29, 2017 10:21 am

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.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8829
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: loadAllRecords( ) on related form if head form is in fin

Postby marco.rossi » Wed Nov 29, 2017 9:17 pm

Hi Joan,
the error is:
Code: Select all
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:

Code: Select all
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
Marco Rossi
Senior Analyst Developer
Freelance Consultant

IT Manager @Mantho
Webmaster @Sitoliquido
marco.rossi
 
Posts: 110
Joined: Sun Apr 12, 2015 9:33 pm

Re: loadAllRecords( ) on related form if head form is in fin

Postby jcompagner » Thu Nov 30, 2017 11:35 am

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.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8829
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: loadAllRecords( ) on related form if head form is in fin

Postby marco.rossi » Thu Nov 30, 2017 7:42 pm

Ok Joan, thank you for your answer.
Marco Rossi
Senior Analyst Developer
Freelance Consultant

IT Manager @Mantho
Webmaster @Sitoliquido
marco.rossi
 
Posts: 110
Joined: Sun Apr 12, 2015 9:33 pm

Re: loadAllRecords( ) on related form if head form is in fin

Postby ROCLASI » Thu Nov 30, 2017 8:41 pm

marco.rossi wrote:Joan

Close, but it really needs an H.
His name is Johan ;)
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Mastodon: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5438
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium


Return to Discuss possible Issues and Bugs

Who is online

Users browsing this forum: No registered users and 4 guests