Cannot find function getName in object

Questions, tips and tricks and techniques for scripting in Servoy

Cannot find function getName in object

Postby Providence1 » Wed May 21, 2014 12:54 am

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.
Providence
Providence1
 
Posts: 451
Joined: Tue Aug 17, 2004 2:36 am
Location: New York, NY

Re: Cannot find function getName in object

Postby Providence1 » Wed May 21, 2014 1:59 am

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?
Providence
Providence1
 
Posts: 451
Joined: Tue Aug 17, 2004 2:36 am
Location: New York, NY

Re: Cannot find function getName in object

Postby lopamudram » Wed May 21, 2014 7:39 am

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
Last edited by lopamudram on Wed May 21, 2014 1:09 pm, edited 1 time in total.
lopamudram
 
Posts: 20
Joined: Wed May 02, 2012 12:05 pm

Re: Cannot find function getName in object

Postby ROCLASI » Wed May 21, 2014 12:38 pm

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.
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Twitter: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5342
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: Cannot find function getName in object

Postby lopamudram » Wed May 21, 2014 1:15 pm

Yes, we need to check if element is instance of RuntimeComponent.
Thanks ROCLASI for rectifying.

Regards,
Lopamudra
lopamudram@mindfiresolutions.com
lopamudram
 
Posts: 20
Joined: Wed May 02, 2012 12:05 pm


Return to Methods

Who is online

Users browsing this forum: No registered users and 3 guests

cron