Hi all,
I was wondering if someone could tell me what property or call I could use to determine the displayType of an element.
I am looping through the elements on a form and need to determine whether or not it is a text area.
Thanks
Hi all,
I was wondering if someone could tell me what property or call I could use to determine the displayType of an element.
I am looping through the elements on a form and need to determine whether or not it is a text area.
Thanks
see: getElementType() on elements
for 6 you can do for example: if (element instanceof RuntimeTextField)
Johan,
Thank you.
Johan,
I made this global method that uses getElementType(), to change the background colour when entering any (named) field on a form via the onElementFocusGained and onElementFocusLost form events. I want only to do this for TEXT_FIELD and TYPE_AHEAD.
function onElementFocusChanged(event) {
var vElem = event.getElementName()
var vEventType = event.getType()
var vForm = event.getFormName()
if (vElem && vForm)
{
var vElementType = forms[vForm].elements[vElem].getElementType();
application.output(vElementType)
if (vElementType == ELEMENT_TYPES.TEXT_FIELD || vElementType == ELEMENT_TYPES.TYPE_AHEAD) // doesn't look nice on combobox
{
if (vEventType == "focusGained")
{
forms[vForm].elements[vElem].bgcolor = '#ffffcc' // pale yellow
}
else { // reset to white on focus lost
forms[vForm].elements[vElem].bgcolor = '#ffffff' // white
}
}
}
}
Works for TEXT_FIELD, but for TYPE_AHEAD fields I get this error
Java class “com.servoy.j2db.scripting.info.ELEMENT_TYPES” has no public instance field or method named “TYPE_AHEAD”.
Checking the Application>Constants node, it’s not there, nor COMBOBOX, even though both are returned with getElementType();
Can you suggest a work around?
Found that this throws an error
if (vElementType == ELEMENT_TYPES.TYPE_AHEAD)
But this works
if (vElementType == “TYPE_AHEAD”)
Which I guess is obvious but I expected all the element types to be in the ELEMENT_TYPES set of constants.
Hi Antonio,
The anomaly of the missing element type constants is something already fixed for the upcoming Servoy 6.
Paul
Thanks Paul, roll on V6!