Error message "controller is not defined"

Questions and answers regarding general SQL and backend databases

Error message "controller is not defined"

Postby Robert Jackson » Thu Jul 08, 2004 11:49 pm

I have 85 value lists that are used in about 40 forms. I use setValueListItems to query the data from a SQL database and polulate each value list. The value lists used in each form are populated using a method that is triggered by the form's OnLoad event. This approach works fine, but results in code duplication and unnecessary processing, since the same value lists are used in multiple forms.

I'd like to consolidate the value list code from all forms into a single global method that runs when the Solution loads. I've tried this but get the error message "controller is not defined" when running the code as a global method. The code is exactly the same as in the form methods, compliles fine as a global method, but will not run as a global method.

I haven't been able to find anything related to this on the forum or in the documentation.

Thanks for your help.
Robert Jackson
 
Posts: 15
Joined: Tue Jun 22, 2004 3:20 am
Location: Voorhees, NJ

Postby IT2Be » Fri Jul 09, 2004 12:43 am

what are your valuelists based on?

relationships, foundsets or custom queries?

when do you set the valuelists? on startup of the application, onLoad of a form?
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Postby jcompagner » Fri Jul 09, 2004 1:12 pm

the solution startup method can't access any controller.
There is no form yet so there can't be a controller.

but why do you need a controller for filling value lists?

Of course you can do this with the onload of the first form you encounter. (do there all the things you want)
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Postby maarten » Fri Jul 09, 2004 3:46 pm

Here's a way a global script would look like, being triggered in a startup script:
(notice that there's no reference to any forms, as they aren't reachable yet during startup)



Code: Select all
var query = "select col1, col2 from table...etc";
var dataset = databaseManager.getDataSetByQuery('serverName', query, null, 100);
var displayValue = dataset.getColumnAsArray(1)
var returnValue =  dataset.getColumnAsArray(2)
application.setValueListItems('myValuelistName',displayValue,returnValue);
Maarten Berkenbosch
User avatar
maarten
 
Posts: 797
Joined: Wed Apr 23, 2003 10:52 pm
Location: Amersfoort, Netherlands

Postby Robert Jackson » Wed Jul 14, 2004 3:08 pm

Thanks Maarten. It looks like this will do the trick.
Robert Jackson
 
Posts: 15
Joined: Tue Jun 22, 2004 3:20 am
Location: Voorhees, NJ


Return to SQL Databases

Who is online

Users browsing this forum: No registered users and 32 guests

cron