Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

URL Genetaror Service

Hi people,

I want my custom Java iView to call another iView by using the request.redirect() method in doOnNodeReady(). For this, I seached SDN to understand how to build the URL for the target iView at runtime. I am trying the following code:

IUrlGeneratorService urlGeneratorService = null;
	<b><u>urlGeneratorService = (IUrlGeneratorService)ResourceFactory.getInstance().getServiceFactory().getService(IServiceTypesConst.URLGENERATOR_SERVICE);</u></b>
} catch (Exception re){
IPortalUrlGenerator portalUrlGenerator = null;
ISpecializedUrlGenerator specializedUrlGenerator = urlGeneratorService.getSpecializedUrlGenerator(IPortalUrlGenerator.KEY);
if(specializedUrlGenerator != null && specializedUrlGenerator instanceof IPortalUrlGenerator){
	portalUrlGenerator = (IPortalUrlGenerator)specializedUrlGenerator;
	myNewParameter = portalUrlGenerator.generatePortalComponentUrl(request, myParameter);

However, I am always receiving a NullPointerException from the line in bold. What I am doing wrong?

Thanks in advance

Fernando Urzedo


Hi Pooja, hi Fernando,

@Pooja: The code you have posted also uses a deprecated method to access the service. I have to admit that the links I referred to within the same thread do this, too (anyhow, you just recreated (deprecated) content already existing on SDN).

See - The non-deprecated way is PortalRuntime.getRuntimeResources().getService()

@Fernando: If you want to use the portal URLGenerator, you have to access it the way described above.

But in your use case, you can use the KM URLGenerator for generating the KM-nav-component URL:

IURLGeneratorService urlGenService = (IURLGeneratorService) ServiceFactory.getInstance().getService(IServiceTypesConst.URLGENERATOR_SERVICE);
redirectStartURI = urlGenService.getRelativeUri(PathKey.NAVIGATION_PAGE).toExternalForm();

Hope it helps


0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question