Are controller specific to a table or not?

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

Are controller specific to a table or not?

Postby swingman » Sat May 01, 2004 4:50 pm

Just having a problem with my custom controller. Can I use the same controller to control layouts from different tables?
User avatar
swingman
 
Posts: 1472
Joined: Wed Oct 01, 2003 10:20 am
Location: London

Postby maarten » Sat May 01, 2004 8:18 pm

Normally one would use the currentcontroller node (under Globals).
It simply executes on the form that's active.
( the(main) form showing next to the controller ).
eg:
"Go to first record" would be like a script attached to the controller form
saying: currentcontroller.recordIndex = 1
Attached to a button on the controller form, it will trigger on all main forms that appear next to the controller form.

If this info doesn't help you, maybe you can describe an example of what you would like to do?
Maarten Berkenbosch
User avatar
maarten
 
Posts: 797
Joined: Wed Apr 23, 2003 10:52 pm
Location: Amersfoort, Netherlands

Postby swingman » Mon May 03, 2004 12:22 am

My buttons work fine with currentcontroller, the problem is with a text label:

I wanted a text label on the controller, displaying "12 of 31" records.
So, I added a label with

"%%recordIndex%% of %%maxRecordIndex%%"

on the controller.

But, when I change the active form, the values displayed seem to be related to the controller table, rather than the active form.

I would not expect a controller have a "tablename" property...
User avatar
swingman
 
Posts: 1472
Joined: Wed Oct 01, 2003 10:20 am
Location: London

Postby Harjo » Mon May 03, 2004 8:10 am

No, is not possible yet!
Look here: http://forum.servoy.com/viewtopic.php?t ... controller
Harjo
 
Posts: 4321
Joined: Fri Apr 25, 2003 11:42 pm
Location: DEN HAM OV, The Netherlands

Postby swingman » Mon May 03, 2004 10:33 am

Thanks HJK!

I will move my "x of y" records to the main forms.

Also, I notice that the controller in the "crm" solution is based on a table called "main".

This will solve another problem I have with my controller:
as it is based on a table with "servoy_row-bgcolor", my controller changed colour too, even though it is set to "record view"!
User avatar
swingman
 
Posts: 1472
Joined: Wed Oct 01, 2003 10:20 am
Location: London

Postby jcompagner » Sun May 09, 2004 12:45 pm

you can get an "xxx of yyyy" in youre custom controller if you want.
Just build "xxx of yyyy" in a global.
And set that global in a onRecordSelection of the forms that uses that custom controller.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8828
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Postby Harry Catharell » Sun May 09, 2004 1:09 pm

I am just trying to resolve what I will show and control from within a custom controller and I would like input on how everybody is working within the limit (sorry, Jan, I mean feature !) of a maximum value of 200 records being returned by the getMaxRecordIndex.

So if you have 300 records in the table or found set etc what would you show as the 'yyyy' value in the 'xxxx' records of 'yyyy' ?

Cheers
Harry
Harry Catharell
 
Posts: 812
Joined: Fri Sep 26, 2003 10:23 am
Location: Milton Keynes, England

Postby jcompagner » Sun May 09, 2004 1:24 pm

it is not really the absoluut maximum. it is the initial maximum.

if you really want the complete count you can do that with
databasemanager.getFoundSetCount(foundset)


of if you know that there aren't thousands of rows you can iterate one time over them..

while(controller.recordIndex < controller.getMaxRecordIndex())
{
controller.recordIndex = controller.getMaxRecordIndex();
}
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8828
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Postby swingman » Sun May 09, 2004 4:02 pm

I have been reading through the Sybase ASA manuals and I'm wondering whether it would make sense to have a table of recordcounts with records for all the large tables, where the counts are updated using triggers on INSERT and DELETE?
User avatar
swingman
 
Posts: 1472
Joined: Wed Oct 01, 2003 10:20 am
Location: London

Postby jcompagner » Mon May 10, 2004 11:36 am

that doesn't work for finds (user finds or related things)
you only have then hard limits of hte complete table. And those shouldn't be to hard for a database to give anyway..
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8828
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Postby Harry Catharell » Mon May 10, 2004 11:46 am

Excuse any SQL naivety but could we not retrieve total records through a SQL query using an aggregate function ?

As in :

SELECT COUNT(*) AS rec_count
FROM client;

Also adding a 'WHERE' clause to filter for a found set count ?

If this is a low overhead process then it may not mean that you have to also have data stored in reference tables and have to handle that administrative processing.

Apologies, but I have been reading my SQL Primer book !! I am not sure how this would be wrapped inside Servoy merthods yet - just writing out loud !!

Harry
Harry Catharell
 
Posts: 812
Joined: Fri Sep 26, 2003 10:23 am
Location: Milton Keynes, England

Postby jcompagner » Mon May 10, 2004 11:54 am

that is exactly what JSDatabaseManager does for you with getFoundsetCount
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8828
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Postby Harry Catharell » Mon May 10, 2004 12:30 pm

Ye Gods - I'm a SQL programmer - It's a miracle !!

No, it's OK - I've just thrown cold water on my face and woken up - I'm only human after all :-(

In reality, I suppose that I am looking for guidance on what is a 'low overhead' process and what is 'expensive' ?

I know that Servoy has initial limits built in to optimise response.

And I recall that the getFoundSetCount function has the 'expensive' warning attached to it.

I guess that I really need to create a mass of dummy records and run some tests.

I cannot believe that any process run in Servoy/SQL would be >= FileMaker's unstored calculation results to get :
"rec 'x' of 'y' found from 'z' total records"

'swingman' - let me know what you decide to do as I am very interested.

Harry
Harry Catharell
 
Posts: 812
Joined: Fri Sep 26, 2003 10:23 am
Location: Milton Keynes, England

Postby swingman » Mon May 10, 2004 1:23 pm

Harry Catharell wrote:'swingman' - let me know what you decide to do as I am very interested.


I'm exploring the issues of moving certain projects to Servoy, so I'm not ready to do any tests just yet. I think I will have to look at how important it is for the client to know exactly how many records they have found and decide to whether to display "1 of 200+" or an exact count.
User avatar
swingman
 
Posts: 1472
Joined: Wed Oct 01, 2003 10:20 am
Location: London


Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 15 guests