cancel
Showing results for 
Search instead for 
Did you mean: 

How to get portal navigation path in English Locale ?

soumalyanath
Explorer
0 Kudos

Hello Experts,

I need to fetch the current navigation path only in English, even if the locale of the portal in changed, in my JSPDyn project in NWDS.

I am using the following Javascript code for the job:

var pathArray = EPCM.getSAPTop().LSAPI.AFPPlugin.model.getCurrentSelectedPath();

var path = pathArray[0].getTitle() ;

for(var index = 1; index < pathArray.length; index++)

{

  path = path +">" + pathArray[index].getTitle();

}

Since the code should be called in a JavaScript function I am unable to use the NavigationEventsHelperService API.

Please suggest if there is any way by which I can get the navigation path in EN Locale using EPCM API.

Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

Amey-Mogare
Contributor
0 Kudos

Hello,

1. Create a new servlet type component inside your portal component DC : -

<component name="AjaxServlet">

<component-config>

<property name="ClassName" value="com.test.nodetranslation.AjaxServlet"/>

<property name="ComponentType" value="servlet"/>

<property name="SafetyLevel" value="authenticated_user"/>

</component-config>

</component>

2. Inside this servlet, write below code to read a URL parameter, say, pageLaunchURL, and get it's title in EN: -

String launchURL = request.getParameter("pageLaunchURL");

IAdminBase adminBaseObj = (IAdminBase)iCtx.lookup(launchURL);

IAttributeSet attrSet = (IAttributeSet)adminBaseObj.getImplementation( IAdminBase.ATTRIBUTE_SET );

String objClass = attrSet.getAttribute(OBJECT_CLASS_PROPERTY);

if("com.sapportals.portal.iview".equalsIgnoreCase(objClass)){

String objectTitleEN = attrSet.getAttribute("com.sap.portal.pcm.Title", Locale.ENGLISH);

}

responseWriter.write(objectTitleEN);

3. Call this servlet from your JSP using ajax call: -

String servletUrl;

%>

<%

servletUrl = ApplicationUtil.encodeURL(componentRequest,"mgi.de~ce~admin~np~wbtrends~portal.AjaxServlet");

%>

servletUrl = "<%=servletUrl%>";

servletUrl +="?path="+iViewLaunchURL;

var oXMLHttp = XMLHttpFactory.createXMLHttp();

var resp;

oXMLHttp.onreadystatechange = function (){

if(oXMLHttp.readyState==4){

resp= oXMLHttp.responseText;

}

}

oXMLHttp.open("GET", servletUrl, false);

oXMLHttp.send();

In 'resp' object, you'll receive iView's title in EN language that was returned by Servlet.

Hope it helps.

soumalyanath
Explorer
0 Kudos

Thanks, it worked.

Answers (0)