Getting the clientId of an XPages button programmatically

牧云@^-^@ 提交于 2019-12-09 13:09:26

问题


When I create a submit button on the form the following is generated in the HTML

XSP.attachEvent("view:_id1:_id2:_id38:_id55", 
    "view:_id1:_id2:_id38:button1", "onclick", null, true, 2);
});

"view:_id1:_id2:_id38:_id55" = the clientId of the eventHandler

"view:_id1:_id2:_id38:button1" = the button clientID (not at all confusing)

Much as I love the Portable Command Guide - I am unable to determine how I can programmatically get the eventHandler clientId.

I need the clientID to submit the form via ajax using the $$xspsubmitid field value

Can this be done through faces? and SSJS?


回答1:


Reading deeper into what you want to do, I think taking a look at this article I wrote sometime back will give you deeper understanding of what is going on. The ID you are attempting to get, the clientId, rather than the targetClientId, is the id of the event handler, which you can get by assigning an id to, for example:

<xp:eventHandler id="foo">

that will force the runtime to use the specified ID rather than an auto-generated one, allowing you to get a handle on it.




回答2:


getComponent("button1").getClientId(facesContext)


来源:https://stackoverflow.com/questions/10147355/getting-the-clientid-of-an-xpages-button-programmatically

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!