simon peter
simon peter

Reputation: 403

How to get an xsp value from URL link using Java

I am trying to retrieve the page name(.xsp)from the URL of the current page using Java. i have been able to accomplish the same thing with the Javascript below

context.getUrl().getSiteRelativeAddress(context).toString()

and it works but i want to get the same thing don using Java.

Upvotes: 1

Views: 622

Answers (1)

Paul Stephen Withers
Paul Stephen Withers

Reputation: 15739

The best way to get SSJS variable names via Java is resolveVariable. This should work:

XSPContext context = (XSPContext) ExtLibUtil.resolveVariable(FacesContext.getCurrentInstance(), "context");
String pageName = context.getUrl().getSiteRelativeAddress(context).toString();

(Updated with correct syntax for second line, thanks Knut)

Upvotes: 3

Related Questions