on 11-28-2014 12:48 PM
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.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.