2
votes

In an xpage I can get the name of the xpage by using

var path:string = facesContext.getExternalContext().getRequest().getRequestURI()
return session.evaluate("@RightBack(\"" + path + "\"; \"/\")").get(0)

(that really is using the path to get the url).

I would like to get the name of the custom control but I think that this is not possible?

1

1 Answers

2
votes

this.getPageName() gives you the name of custom control name on custom control's main level. Write name into dataContext "name" and use it inside your custom control:

<?xml version="1.0" encoding="UTF-8"?>
<xp:view
    xmlns:xp="http://www.ibm.com/xsp/core">
    <xp:this.dataContexts>
        <xp:dataContext
            value="#{javascript:this.getPageName()}"
            var="name">
        </xp:dataContext>
    </xp:this.dataContexts>
    <xp:text
        escape="true"
        id="computedField1"
        value="#{name}">
    </xp:text>
    ab
</xp:view>