Using element name in Components

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

azaleas
Ebase User
Posts: 81
Joined: Thu Jul 30, 2015 12:44 pm

Using element name in Components

#1

Postby azaleas » Mon Nov 16, 2015 7:12 am

On my regular forms, I use event.getOwner().elementName to initialize my scripts. But apparently, it doesn't work with components. I just have 2 scripts, one for each button in the Component. So, I want to use:

if (event.getOwner().elementName == "button1ControlName"){
do sth
}

if (event.getOwner().elementName == "button2ControlName"){
do sth
}


This way, I can reduce the script to one file. Any ideas?
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#2

Postby Jon » Mon Nov 16, 2015 10:55 am

event.getOwner().elementName is returning the full name of the button with the component prefix added to the front of the name. You could use:

Code: Select all

if (new java.lang.String(event.owner.elementName).endsWith("button1ControlName"))
..
(This uses the Java String class instead of the Javascript String because the Javascript version doesn't have an endsWith method.)
0 x


Who is online

Users browsing this forum: No registered users and 17 guests