Hello,
I have come across a strange problem. Fortunately I could isolate the matter:
- I worked on a form did this and that, everything OK
- I used “toggle form commands” to get rid of those nasty “delete all” etc.
- All of a sudden I got this ReferenceError
- I created a new form, error was gone
- When later I used “toggle form commands” again, I had my ReferenceError again
- This time I figured it was one of the commands: I only get this error if onShowAllRecordsCommand is set to none
Hope this helps to fix it…
ReferenceError: “wiedervorlage_am” is not defined. (_onShow; line 2)
at org.mozilla.javascript.NativeGlobal.constructError(NativeGlobal.java:580)
at org.mozilla.javascript.NativeGlobal.constructError(NativeGlobal.java:540)
at org.mozilla.javascript.ScriptRuntime.name(ScriptRuntime.java:1102)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2003)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:94)
at com.servoy.j2db.scripting.e.call(Unknown Source)
at org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1242)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:1942)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:94)
at com.servoy.j2db.scripting.e.call(Unknown Source)
at com.servoy.j2db.develop.debugger.k.a(Unknown Source)
at com.servoy.j2db.develop.debugger.k.executeFunction(Unknown Source)
at com.servoy.j2db.FormPanel.a(Unknown Source)
at com.servoy.j2db.FormPanel.a(Unknown Source)
at com.servoy.j2db.FormPanel.a(Unknown Source)
at com.servoy.j2db.FormPanel.cy(Unknown Source)
at com.servoy.j2db.FormManager$7.run(Unknown Source)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
I have just run into the same problem, but my “fix” doesn’t work. This time I have a different behaviour: If I have the debugger turned on, I don’t get this error. If I don’t, I get it.
Can this be fixed?
I found a workaround for this one also:
- The problem occured in an onRecordSelection that called a form method of another form of the same table
- In that other form method a field was referenced (resulting in this error)
- I could fix it by creating a onRecordSelection method in the other form and check the field there
in both cases: Was there data in the form where the error occurs?
Are you really sure that for example: foundset.getSize() was returning > 0?
(right before accessing the value)
Yes, there were records. But there seems to be something wrong with the onShowAllRecords form property anyway. If you set that to none, you see no records onLoad, although the property should only apply when a user wants to hit ctrl-J, doesn’t it?
i have no idee what you are exactly saying (see no records onLoad??). Please give an example what you mean.
2> yes you need to set the data then yourself. the show all records will not happen.
Because of this there is no data/no records so a reference error could occur.
so a reference error could occur.
and is this expected behaviour if there are no records? I don’t think I like this. Sometimes there is no record but you check for a field anyway. Instead of a referenceError I’d prefer to get null then…
you are just checking a record?? Without knowing what you check? This i find very strange.. How do you know what you check? Record X record Y? No record??
What should we return if you ask for data? null? Maybe that is something you check for and you don’t want null but it has to be filled in. But the problem is what to fill in because the record isn’t there…
check for the size or the selectedindex …
Let’s say I do something like this onShow of a form
if (field == 'ABC')
{
forms.form.elements.button_x.visible = true;
}
If I have no records, I get an error saying that field is not defined. That is not true. Field is defined, there are just no records loaded. In that case I would prefer that field evaluates to null.
no there isn’t there is really nothing defined. There is no record. So there is no field that can return anything.
And given youre example:
if (field == null)
{
forms.form.elements.button_x.visible = true;
}
what then? very strange results if no record did return something. Because a button appears on the form that was triggerd by a value of a record that isn’t even there…
You just have to check if there are records:
if (controller.getSelectedIndex() > 0 && field == ‘ABC’)
{
forms.form.elements.button_x.visible = true;
}
(or use getMaxRecordIndex())
I have that problem also in a bgcolor calculation. I use one of the columns in the table the form is based on as criteria for bgcolor settings. Since I don’t know when I am getting errors telling me that something in my calc is undefined. There is nothing special about the form that could lead to a situation where there are no records. I still get that error and after I get it I’m almost “dead” inside Servoy. When I toggle between design and browse mode, I have 100% CPU and it takes minutes to load.
Are you saying that a it tries to do the calculation when there are no records. But that no records should happen anyway?
that i would like to see in an example