cancel
Showing results for 
Search instead for 
Did you mean: 

How to get URL to portal component?

Former Member
0 Kudos

Dear Experts,

I have the following question

I deploy par-file to portal with two components inside. I need to call one component from another via URL. How can I get URL of the component?

The simplest way to solve my problem is:


response.write("<a href="https://answers.sap.com/irj/servlet/prt/portal/prtroot/<componentName>">link</a><br>n");

But I think it is not the best solution for such problem because "/irj/servlet/prt/portal/prtroot/" constant which may be changed in future.

Do you have any suggestion how to get relative (or absolute) URL of the current component?

Thanks many times,

Egor.

Accepted Solutions (1)

Accepted Solutions (1)

detlev_beutner
Active Contributor
0 Kudos

Hi Egor,

first, welcome on SDN

About your question:

Use the IPortalUrlGenerator, see http://www.ajvic.net/irj/portalapps/com.sap.portal.pdk.srv.urlgenerator/docs/urlgeneratorcomponent.h... and/or (Apr 29, 2004 10:12 AM).

Hope it helps

Detlev

PS: Please consider rewarding points for helpful answers on SDN. Thanks in advance!

Answers (3)

Answers (3)

Former Member
0 Kudos

Hello!

First of all, guys, thanks a lot for your answers! It was really useful!

I regret that there is no possibility to award each of you by 10 points. Therefore I awarded 10 points to Detlev and 6 to Pooja just because of Detlev was first.

Former Member
0 Kudos

Hi Detlev,

The code that i have posted..i think it gives a direct explanation to the query that Egor has asked. I thought it'll be of some help in addition to the links that you have sent.

Regards,

Pooja.

Former Member
0 Kudos

Hi Egor,

Suppose u have to call one iview from another...See this code:

Every iView is based on the par file..

So u will be having the 2 par files 2 iViews.

First write the on method in your controller in JSPDynPage or abstract portal componet which is a controller to ur iView when u want to call another view.

In that controller you have to import a classes called

import com.sapportals.portal.prt.service.urlgenerator.IUrlGeneratorService;

import com.sapportals.portal.prt.service.urlgenerator.specialized.IPortalUrlGenerator;

import com.sapportals.portal.prt.service.urlgenerator.specialized.ISpecializedUrlGenerator;

And in the specific method where u want to call the another iview you have to have the following code:


//Get the request, context and profile from portal platform
compRequest = (IPortalComponentRequest)this.getRequest();
IUrlGeneratorService urlGen = (IUrlGeneratorService)compRequest.getService(IUrlGeneratorService.KEY);

// get Specialized Portal Url Generator
IPortalUrlGenerator portalGen = null;
ISpecializedUrlGenerator specUrlGen = urlGen.getSpecializedUrlGenerator(IPortalUrlGenerator.KEY);

if(specUrlGen != null && specUrlGen instanceof IPortalUrlGenerator){

String strNewiViewComp = "";
portalGen = (IPortalUrlGenerator)specUrlGen;
strNewiViewComp = compProfile.getProperty("secondivewparfilename"); 

url = portalGen.generatePortalComponentUrl(compRequest, strNewiViewComp);

In the above code strNewiViewComp = compProfile.getProperty("ClaimDetailsComponent");

is used to get the another iViews par file which is configured in default.properties file

your default.properties file should contain "secondivewparfilename" value assigned .

This will take you to the new iView.

Regards,

Pooja.

detlev_beutner
Active Contributor
0 Kudos

Hi Pooja,

that's what behind the links I've offered...

Egor: Please consider... (see above)

Best regards

Detlev