cancel
Showing results for 
Search instead for 
Did you mean: 

Get Portal User Info from WebDynpro

Former Member
0 Kudos

Hi All,

Instead of going ahead with the old loop I am creating this new Thread.

I am getting null pointer exception when I try to get the IUser.what could be the solution?

Regards,

Shakthi

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

1. First U open ur WebDynpro Application in NWDS

2.right click on application name

3.click on edit

4.click on "application properties" tab button

5.next click on "new"

6.select "predefined" radiobutton

7.select "authentication" from list.

8.specify value as "true".

9.click on "ok"

10.Rebuild project .

11.Deploy and Run.

now u will get login screen .

in login screen try to login with different users of the Portal system.

and check whether it has displayed user info or not.

but dont forget to write ur code which was written earlier by u

Former Member
0 Kudos

Thank

Former Member
0 Kudos

Hi Shakthi,

This might be a stupid question, but when you say you get null, do you deploy and run direct from NWDS?

Because if you do, you are not logged in with a user...

Have you tried implementing and running application in a portal? It worked for me.


String firstName = null;
    String lastName = null;
    IWDMessageManager messageManager = this.wdThis.wdGetAPI().getComponent().getMessageManager();
    
    try{
    IWDClientUser wdUser = WDClientUser.getCurrentUser();
    IUser user = wdUser.getSAPUser();
    firstName = user.getFirstName();
    lastName = user.getLastName();
    }
    catch(Exception e){
		wdComponentAPI.getMessageManager().raiseException(e.getMessage(),true);
    }
    messageManager.reportSuccess("First name:" +firstName);
	messageManager.reportSuccess("Last name:" +lastName);

Regards,

Simon

Former Member
0 Kudos

Hi,

are your WAS and EP in same machine or in different machines

Regards

Rohit

Former Member
0 Kudos

Hi Rohit,

How to check that?

Regards,

Shakthi

Former Member
0 Kudos

Hi Sakthi,

The ip address or machine name which you specify in the NDS for deploying webdynpro projects and the ip address or machine name which you specify in the url of Portal. check if both are same

Regards

Rohit

Former Member
0 Kudos

Hi Rohit,

Both are same.

Still I am getting null IUser.

Regards,

Shakthi

detlev_beutner
Active Contributor
0 Kudos

Hi Shakti,

I don't know the old thread - could you at least provide the code fragment you are using?!

Thanks in advance

Detlev

Former Member
0 Kudos

public void onActionGetPortalUserInfo(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )

{

//@@begin onActionGetPortalUserInfo(ServerEvent)

String firstName=null;

String lastName=null;

String cellPhone=null;

String city = null;

IWDMessageManager messageManager = this.wdThis.wdGetAPI().getComponent().getMessageManager();

try {

IUser user = WDClientUser.getCurrentUser().getSAPUser();

try{

firstName = user.getFirstName().toString();

lastName = user.getLastName().toString();

cellPhone = user.getCellPhone().toString();

city = user.getCity().toString();

}catch (NullPointerException nle){

messageManager.reportSuccess("inside catch block "+nle.toString());

nle.printStackTrace();

return;

}

messageManager.reportSuccess("First Name : "+firstName);

messageManager.reportSuccess("Last Name : "+lastName );

messageManager.reportSuccess("Cell Phone : "+cellPhone );

messageManager.reportSuccess("City : "+city );

wdThis.wdGetContext().currentPortalUserInfoElement().setFirstName(firstName);

wdThis.wdGetContext().currentPortalUserInfoElement().setLastName(lastName);

wdThis.wdGetContext().currentPortalUserInfoElement().setCellPhoneNumber(cellPhone);

wdThis.wdGetContext().currentPortalUserInfoElement().setCity(city);

}

catch (Exception e) {

messageManager.reportException(e.getMessage(),true);

}

//@@end

}

Former Member
0 Kudos

hi Sakthi,

You should create a webdynrpo iview for that

see the link

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/webas/webdynpro/po... integration of web dynpro applications.pdf

hope this helps you

Regards

rohit

Former Member
0 Kudos

Hi Rohit,

I have created this thread for finding out the users who are all deploying in WAS.

But you have given me a link which is telling us to integrate our WebDynpro application in SAP Portal.

But the link sent by you helped me a lot.

Thank you very much.

Regards,

Shakthi

Former Member
0 Kudos

Have you solved your problem yet Shakthi?

In order to get the user, you have to define the sap locale system when creating the view. Have you done that?

Former Member
0 Kudos

Swapna,

I do not have exact code snippet but i can give you a direction.

If you get the iview Object you can get all the properties of the Iview and that includes the one who created the iview.

So try to see how you can get the iview object

Former Member
0 Kudos

Hi Swapna,

I gave the link since you asked in the other thread how to call webdynpro applications in portal

I am assuming you have created a webdynpro iview for displaying the application.The iview should be under a role and you should assign the role to a user.

Only when you login through portal you will get the user.Otherwise if it will be null only

Also since your WAs and EP are on same machines, when creating the webdynpro iview give SAP_local system

Regards

Rohit

Former Member
0 Kudos

Hi All,

First of all Thankyou for all of your support to develop SAP products.

Where should I give SAP_local system.While calling WebDynpro iView where should I give SAP_local exactly.

Could youplease help me in this?

Regards,

Shakthi

Former Member
0 Kudos

Hi All,

I am trying the same setting as you said...I'll let you know once I finished this.

Regards,

Shakthi

Former Member
0 Kudos

If you create a new SAP Dynpro view, you get an dropdownbox where you asked to choose a system. Sap local system is defined in this list, so you should choose that