new records produce java.lang error

Hi Guys,
I have included a .doc file to try to show my problem and hopefully it can explain better than I can.

I have a main form that has tab forms in it. When I create a new record using a tab form, the currentcontroller is called (from the main form) and a new record window pops up. It creates a new record, and any information entered in the tab form is put into the database correctly, but then when the information is saved into the database, the information disappears from the form.

Code used to create the record is:

var formName = elements.Employeemain.getSelectedTabFormName();
if(formName == “Employee”)
{
var formName = null;
currentcontroller.newRecord();
var userName = security.getUserName();
forms.Employee.recordcreatedon = application.getTimeStamp();
forms.Employee.recordcreatedat = application.getTimeStamp();
forms.Employee.recordcreatedby = userName;
}

The interesting part is - If I have 200 records loaded (for example) and I do a new record - it inserts it as 201. When the data is saved the 201 is shown as the record I’m on, but no data. If I try to enter data on that screen, then I get the java.lang error.

If I then go to the end of the total foundset and load all records the data shows up as the next number in the index (1692) and the data shows in the form. If I am on the last record in the foundset, and create a new record, then the data disappears until I stop and start the application in order to reread the databases.

I am using Linux Fedora Core 4
Servoy Server version 2.4.4

We’ve been using this application quite successfully for about 5 months now, and this is a new occurrence. Any help would be greatly appreciated, since I am totally stumped.

Thanks in advance for helping me out.

Graham

newrecord.doc (373 KB)

What is the exact error that you get? Could you post the full error from the log?

But I also find the approach of using currentcontroller a bit strange (what happens for example if currentcontroller points to some other form). Why don’t you write

var formName = elements.Employeemain.getSelectedTabFormName();
if(formName == "Employee")
{
forms[formName].controller.newRecord();
forms[formName].recordcreatedon = application.getTimeStamp();
forms[formName].recordcreatedat = application.getTimeStamp();
forms[formName].recordcreatedby = security.getUserName();
}

or even nicer

if(formName == "Employee")
{
var newRecord = forms[formName].foundset.getRecord(forms[formName].foundset.newRecord(false, true));
newRecord.recordcreatedon = application.getTimeStamp();
newRecord.recordcreatedat = application.getTimeStamp();
newRecord.recordcreatedby = security.getUserName();
}

Additionally you could consider using autoenter properties for creation date and creation user name. Just check out the auto enter properties of the dataproviders used.

Thanks Patrick,
I appreciate your advice. The code you suggested works in the developer, but not in the client. I enter the new record in the client, and it creates a newrecord, but nothing shows on the form once the data is saved. I have to reload the application to get the data to show in the form.

I looked at the log, but there are no errors or information other than the output statements I have inserted to try to figure this out.

I no longer get a java.lang error though when I enter data into the new record.

Here’s the relevant output from the log.

Java Web Start 1.4.2_08 Console, started Thu Mar 09 10:00:39 MST 2006
Java 2 Runtime Environment: Version 1.5.0_06 by Sun Microsystems Inc.
Logging to file: C:\Servoy\javaclient.log
Starting Servoy from C:\Documents and Settings\grahamm\Desktop
Servoy R2 2.2.4 build-336 on Windows XP using Java 1.5.0_06

Username = mountain
user:admin
user:ames
user:ami
user:bell
user:bernick
user:brekke
user:burris
user:cloninger
user:comer
user:demaria
user:dempsey
user:garcia
user:green
user:gross
user:harrop
user:ho
user:hoge
user:judy
user:king
user:kosley
user:kramer
user:lathrop
user:lewis
user:mcauley
user:mckie
user:meshek
user:mountain
group: Master
user:pantyukh
user:pendergrass
user:pomeroy
user:pomper
user:regnier
user:richard
user:rush
user:sawyer
user:schubert
user:sperry
user:steffen
user:swenson
user:takamura
user:zellers
Username = mountain
Username = mountain
Username = mountain

Graham

Hi Patrick,
I added an extra statement to the code at the end to show the Employee_Main form, and that seems to have solved the data showing problem.

I appreciate your time and advice. I’m learning as I go, so I take all the advice I can from the experts.

Thanks again for you time and advice.

Graham