Problem getting the ID of the current element on XPage

Hi ,

I am trying to do a very simple thing but am facing with a lot of issue. Please help me if you find time.

My issue is as follows,

I have a Button control in my XPage. On click of this button, I need to get the ID of the same in Notes Client 8.5.1.

I have no clue of how to get the id of the button programatically. And believe me it is so very vital for me to accomplish this in order to proceed with my project’s design, which has been created after 2 months of deep analysis. I cant say no and i must do this.

I tried alert(this.name) in the onclick event of the button , but that gives me an empty string as the result, where as the same on a plain form even in Notes Client.

Hence I tried the following code after a lot of trails and research,

var objName = (java.lang.String) (this.name); //my machine freezes when this code is executed

alert(objName);

and that has left me a far bigger issue that my machine hangs for at least 10 minutes,

/********************/

Java™ Plug-in Fatal Error

cannot load class sun/plugin/JavaRunTime

The Bridge was installed at <C:\Prohra~1\Java\JRE16~1.0_0> but the class is not there

Modify tge registry key to reflect the new bridge location

The Key is HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Plug-in

or change your CLASSPATH to include the new directory

Please consult the documentaton for more information

/********************/

I am clue less. I dont want to update my windows registry. I am afraid if that would affect other stuffs on my machine.

please suggest me a work around

How ever, I have managed to grab the properties of the XPage Element and the list of properties bound to that button object are as follows, and I dont think any of these properties will give me what I am looking for … I have tried alerting atleast 50 properties though…

view__id1__id7_clientSide_onclick

view__id1__id5_clientSide_onclick

clearFormHiddenParams_view__id1

onerror

XSPRCPConstructor

ibm

XSPConstructor

XSP

onunload

addEventListener

location

document

window

dojox

dijit

dojo

console

navigator

Packages

sun

java

netscape

XPCNativeWrapper

GeckoActiveXObject

Components

setTimeout

name

parent

top

scrollbars

scrollX

scrollY

scrollTo

scrollBy

getSelection

scrollByLines

scrollByPages

sizeToContent

dump

setInterval

clearTimeout

clearInterval

setResizable

captureEvents

releaseEvents

routeEvent

enableExternalCapture

disableExternalCapture

prompt

open

openDialog

frames

find

self

screen

history

content

menubar

toolbar

locationbar

personalbar

statusbar

directories

closed

crypto

pkcs11

controllers

opener

status

defaultStatus

innerWidth

innerHeight

outerWidth

outerHeight

screenX

screenY

pageXOffset

pageYOffset

scrollMaxX

scrollMaxY

length

fullScreen

alert

confirm

focus

blur

back

forward

home

stop

print

moveTo

moveBy

resizeTo

resizeBy

scroll

close

updateCommands

atob

btoa

frameElement

removeEventListener

dispatchEvent

getComputedStyle

sessionStorage

globalStorage

Thanks in advance

Subject: issue resolved

The solution is posted in the following location,

Thanks and Regards,

Karthick

Subject: How to get it in SSJS when you are in a button

That comes years later but maybe it will help somebody. I was in the situation to need an action depending on the name or the component ID of the button clicked for SSJS calculations without CSJS.

If you call following code in the onClick event of this button:

var currId = this.parent.id;

you get exactly the button’s name (like “button1left”) set in the properties.

If this name contains a reference to a specific action, this action can be carried out by a central SSJS function knowing that exactly this button was clicked.

Subject: solution

I assume you are using client side javascript. So, use the following:

document.getElementById(“#{javascript:getClientId(“yourID”)}”).name

Howard

Subject: Getting id of control

There are a variety of options. You can use server-side javascript to evaluate the id. This can be placed in client-side javascript on your XPage or in an output script block (it won’t work in a javascript library). So e.g.var myId=“#{id:myElement}”

This will get the full id of an element called myElement.

Alternatively, you can use a computed text element to capture the prefix for the relevant custom control and build accordingly. See my responses here: http://www-10.lotus.com/ldd/nd85forum.nsf/5f27803bba85d8e285256bf10054620d/c1111cabc4fb21e4ca257607001a670d?OpenDocument&Highlight=0,xpages,id,client

Both options are fairly well documented by various XPages experts on the web.

Subject: Re: Getting ID Of Control

Hi Paul,

Thanks for taking time in replying me. Your posts(links) are useful to me, but its not what I am looking for. Let me make my question simpler and clearer,

Let me assume that I have a html button on a XPage as follows (I had put this code directly into the Source tab and it works ),

So Now on my Notes Client I see a button named “HTMLButton” which upon clicking gives me an alert saying “MY_ID”

The same way I want the ID or Name of a Button Control, created on an XPage by dragging and droping from the Control Palette, be alerted upon clicking the same.

I dont want to hard code my button control’s name any where in the code, as was suggested.

that is the getComponent(‘elementName’) - this is a dependency on the elementName which I cannot afford to have.

Thanks and Regards,

Karthick