Page 1 of 1

Cannot find function getName in object

PostPosted: Wed May 21, 2014 12:54 am
by Providence1
Can someone tell me what this means:
Code: Select all
Cannot find function getName in object com.servoy.j2db.smart.dataui.DataRenderer[Body,0,0,1020x657,invalid,layout=com.servoy.j2db.util.gui.AnchorLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=16777225,maximumSize=,minimumSize=,preferredSize=java.awt.Dimension[width=1019,height=605]]


My users are running into it seemingly randomly.

Re: Cannot find function getName in object

PostPosted: Wed May 21, 2014 1:59 am
by Providence1
This might be more helpful:

This:
Code: Select all
if (utils.stringLeft(forms[currentForm].elements[elm].getName(), 4) == 'fld_') {

(where currentForm = "qs_quotes_dtl" and elm = "Body")

gives me this:

"Error during evaluation:TypeError: Cannot find function getName in object com.servoy.j2db.smart.dataui.DataRenderer[Body,0,0,1020x657,invalid,layout=com.servoy.j2db.util.gui.AnchorLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=16777481,maximumSize=,minimumSize=,preferredSize=java.awt.Dimension[width=1019,height=605]]."

Can I assume my issue is with whatever is in the Body that is returning 'invalid' in the DataRenderer?

Re: Cannot find function getName in object

PostPosted: Wed May 21, 2014 7:39 am
by lopamudram
Hello Providence1,

It throws error because there are no such element with the name "Body" exists in the forms.
You can print elements.allnames and check elements for the forms. As a solution:

1. We can check if the elements[elem] is instance of RuntimeComponent before proceeding.
2. Unless we are doing some manipulations to the form at runtime, we do not need to attach the onRender event at form level. We can select multiple fields in the form and attach the same onRender event to the elements.

Hope this helps.

Thanks,
Lopamudra
lopamudram@mindfiresolutions.com

Re: Cannot find function getName in object

PostPosted: Wed May 21, 2014 12:38 pm
by ROCLASI
I just spoke with Johan Compagner and this is a bug that is fixed in 7.4.1 (now in RC).
It's not specifically related to onRender but to events in general.

So I guess as a workaround you can check if the element is an instance of RuntimeComponent.
Checking for JSComponent or JSField doesn't work. These classes are used on the blueprint, i.e. the Solution Model. Not in the actual runtime instance.
So the code could look like this:
Code: Select all
var _aElements = elements.allnames;
for ( var i = 0 ; i < _aElements.length ; i++ ) {
    if ( elements[_aElements[i]] instanceof RuntimeComponent ) {
        // your code
    }
}


Hope this helps.

Re: Cannot find function getName in object

PostPosted: Wed May 21, 2014 1:15 pm
by lopamudram
Yes, we need to check if element is instance of RuntimeComponent.
Thanks ROCLASI for rectifying.

Regards,
Lopamudra
lopamudram@mindfiresolutions.com