How to get Portal User Context  in Web Dynpro application

I have successfully integrate a web dynpro app into SAP Netweaver Portal.
Within my web dynpro app, how can I get portal user context information such as first name, last name, job title or some newly created ume attibutes.
Is there any programmatical approach to get portal user context in my web dynpro. I not sure whether I can use the following codes in web dynpro?
IUserContext userContext = request.getUser();
String firstName = userContext.getFirstName();
String lastName = userContext.getLastName();
If yes, can someone point me the name of the jar file I have to import.
Note : The SAP Netweaver installation that runs my web dynpro app is same with the SAP Portal.

Hi ,
you can use the below code to get User details and  add com.sap.security_2.0.0 > lib > com.sap.security.api.jar
try
          IWDClientUser clientUser = WDClientUser.getCurrentUser();
String firstName = clientUser.getFirstName();
String lastname = clientUser.getLastName();
catch (WDUMException e) {
            wdComponentAPI.getMessageManager().reportException("Error Retrieving User"+e.toString(),true);
Regards,
Sunitha Hari

Similar Messages

  • How to get Portal user from a standalone Java application

    Hi,
    I have a standalone Java application from where I need to fetch the Portal User Information like userid and email id.
    I am using the below line of code
    iUser = UMFactory.getUserFactory().getUserByLogonID("e017939");
    I have included the jar file com.sap.security.api , But it was giving me the below exception
    java.lang.NoClassDefFoundError: com/sap/tc/logging/Location
         at com.sap.security.api.UMFactory.<clinit>(UMFactory.java:55)
         at com.am.wcas.java.mailscheduler.kmaccess.FetchDataFromKM.getiUser(FetchDataFromKM.java:29)
         at com.am.ScheduleEmails.main(ScheduleEmails.java:89)
    and I am getting a pop Up message from the Java Virtual Machine Launcher, saying a Fatal Exception has occured and the Program will exit.
    Then I went throught he SDN threads and they asked me to include the
    logging.jar and com.sap.security.perm.api .
    I Included them, then also, it is giving me Exception
    java.lang.NoClassDefFoundError: com/sap/engine/lib/logging/LoggingHelper
         at com.sap.security.api.UMFactory.<clinit>(UMFactory.java:56)
         at com.am.FetchKMData.main(FetchKMData.java:30)
    Exception in thread "main"
    and I am getting a pop Up message from the Java Virtual Machine Launcher, saying a Fatal Exception has occured and the Program will exit.
    Kindly let me know if it is possible to access the User info using UMFactory in a standalone Java application. If yes kindly let me know where i am going wrong.
    Regards,
    Shilpa B.V

    Hi Shilpa,
    1. Check that you have added com.sap.security.api within the Your Project>Libraries folder (under navigation tab) and also added jars in the build path of the Your Project under project>properties>Build Path.
    2. In case you have a DC instead of Web Dynpro Project then you have to add the com.sap.security.api under Your DC>Used DCs and have compile time and runtime dependency added.
    Here java.lang.NoClassDefFoundError is caused basically due to only build time dependency added and reference to the jar missing at runtime. Rest the code to retrieve the current user id using UME API and getUserByLogOnID("....") method with/without portal environment would not be an issue at all.
    Regards,
    Tushar SInha

  • Need info on Accessing portal services within a Web Dynpro application

    Hi,
    I need information on Accessing portal services within a Web Dynpro application.I want to explore this topic.Can anyone give useful links?
    Thanks in advance.
    Rajani N

    Hi
    how to reference  a portal service with web dyn pro ?
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/ep/how%20to/how%20to%20access%20a%20portal%20service%20within%20a%20web%20dynpro%20java%20application.pdf
    http://help.sap.com/javadocs/NW04S/current/wd/com/sap/tc/webdynpro/clientserver/portal/WDPortalUtils.html
    Best Regards
    Jakub Krecicki

  • Access users in a Web Dynpro application on different WAS ??????

    Hi,
    Scenario - I have a local WAS on which i have deployed a Web Dynpro Based application.
    There is another WAS on which I have portal installed. I need to access the roles assigned to a particular user in my Web Dynpro application.
    Query -
    I need to know can i access the roles assigned to a user on a different WAS in a Web Dynpro based application running on a different WAS.
    Thanks and Regards,
    Amol Ghodekar.

    Amol,
    as this questions existed twice, I've deleted one.
    As roles are in the UME, you can access them. But why do you want to do this? You could login to that user, but then the question is what you want to do....
    Regards,
    Benny

  • How to get User Id in Web dynpro application

    Hi Experts,
    I am running web dynpro application with authentication checkbox set. I want to display user id of the user in my application. I am using following code in Init method of component controller.
    IWDClientUser wdUser = WDClientUser.getCurrentUser();
    WdContext.currentContextElement().setUserName           (wdUser.getClientUserID());
    Here I am getting some integer value as userId.
    I am not using Portals, so solutions suggested for portal are not useful for me .
    Is there any way to get this uset id.
    Thanks in advance

    hi
    try this piece of code
              IWDClientUser wdUser = WDClientUser.getCurrentUser();
              IUser user = wdUser.getSAPUser();
              if (user != null)
                        IUserAccount[] acct = user.getUserAccounts();
                        if(acct[0] != null)
                                  String strUserid = acct[0].getLogonUid();
    wdContext.currentZtms_Fm_Regupdate_InputElement().setAssoid(new String(strUserid));
    Note: Defining the IUser will show an error. To resolve this, within the properties of
    the project, choose Java build path -> Libraries -> Add external jars ->
    com.sap.securities -> lib -> com.sap.security.api. Open this file and retype the code.

  • Storing user defaults of Web Dynpro application on portal

    Hi folks,
    I am trying to develop Web Dynpro application that runs in an iView on a portal. I would like to remember certain user defaults for this application (e.g., user default plant). User also has control over this value, so whenever they change it, the value should be update on a backend as well.
    My first thought was to use PCD, but I am not sure how to do that - all the code examples for I found for PCD looked like they were created for portal application, not Web Dynpro ones.
    Anybody here actually done anything similar?
    Edited by: Alexei Isaev on Jan 29, 2008 8:20 PM

    Hi Alexei,
    If you need to store default values for a portal application, you may consider your development in Web Dynpro for ABAP.  I have not come across application level personalisation yet in Web Dynpro for Java, unless someone else can throw some light here.
    Regards,
    Subramanian V.

  • How to make use of Portal service in the web dynpro application

    hi
    I have some portal service and how to use that in the web dynpro application.
    and also what is the main diff between Portal Component and web dynpro application.
    do we required portal to run web dynpro application.
    thanks
    mmukesh

    Hi,
    >> I have some portal service and how to use that in the web dynpro application.
    Yes. U can use Portal service in webdynpro. Check the link given by subathra.
    >> and also what is the main diff between Portal Component and web dynpro application
    Portal Components are components designed to run in portal server while webdynpro application can run in J2EE WebAS.
    >> do we required portal to run web dynpro application.
    No for general cases. Just WebAS is sufficient to run webdynpro appl. But if u use portal service in ur webdynpro appl, then make sure both (portal service and webdynpro appl) run on same J2EE engine. That is mandatory.
    Regards,
    Vijai

  • How do i pass parameters to a web dynpro application ?

    Hi all,
    how do i best possible pass (serverspecific) parameters to a web dynpro application ?
    i wrote a web dynpro application that, among other things, sends an email and stores files on a server directory. Therefor i need parameters like e.g. "mailhost" or "directory".
    The way i chose is to make a *.properties file. But from my point of view there are some disadvantages.
    1) When i deploy the WD App to a new server, i have to edit the properties file before. I don't know how to do that. Do i have to edit the *.properties file again, before i make a new ear-Archive with NWDS ?
    2) When the properties a wrong or change for a deployed app, i have to restart the J2EE Engine. Thats not convenient for a production server.
    Is there a better way ?
    Thanks
    Andreas
    (And I promise to return and reward the answers)

    Hi Andreas,
    You can't use something like portalapp.xml because this is not supported by webdynpro, but ... you can add this parameters at the end off the webdynpro address line. like http://<host>:<port>/webdynpro/dispatcher/local/<Webdynproproject>/<webdynproApplication>?host=yourhost
    In your application you can get these variables:
    String host = WDWebContextAdapter.getWebContextAdapter().getRequestParameter("host");
    when you create a webdynpro iview you can specify the default value for the variables in the URL in the properties of the iview and i think you can personalize them later.
    kind regards,
    Joachim

  • How to Debug a BAPI from a Web Dynpro application

    I have a Web Dynpro application calling a BAPI, and I would very much like to see what data the Web Dynpro application is passing into the BAPI, and then debug the BAPI.
    Is there a way to do this? I'm wondering if it is possible to somehow set up the ABAP stack so that on receipt of the BAPI call, it appears on the tRFC queue waiting for execution.
    However it is done, I need a way to step through the BAPI on the ABAP stack.
    BR,
    Tony.

    Hi Anthony,
    The ABAP runtime environment contains various tools that you can use for analysis purposes, such as for debugging source code. All source code written for Web Dynpro applications in ABAP can normally be tested using the debugger.
    To allow it to test other Web Dynpro-specific program entities too, the debugger has been equipped with a special enhancement. In the phase model in the active application, you can typically see the following information at various points in time:
    -The structure of the content of the current controller,
    -The properties of the UI elements in the layout of the current view
    -The currently instantiated component usages
    Starting the Debugger
    The functions for debugging Web Dynpro entities are embedded in the new debugger. You therefore need to have selected the new debugger in your Workbench settings.
    Selecting the New Debugger
    1. In the menu, choose Utilities -> Settings.
    2. A dialog box now appears that contains two nested tab page areas. Choose the “parent” tab page ABAP Editor.
    3. The settings for ABAP Editor always open with the content of the child tab page Editor. Here, select Front End Editor (New).
    4. Now switch to the Debugging tab page in the ABAP Editor settings and select New Debugger.
    5. Save your changes and close the dialog.
    Starting the Debugging Process
    To run an application in debugging mode, you first need to set an external breakpoint in display mode in one of the methods in the component.
    Now start a test run of the application from ABAP Workbench as usual.
    The method in which you set the breakpoint depends on the purpose of the test run. To debug a view, for example, it is best to set the breakpoint in method WDDOMODIFYVIEW. Provided that the context of the view controller is not filled using a supply method, the view is fully instantiated in the phase model at this point in time.
    Selecting the Web Dynpro Tool in the New Debugger
    When you start the application, another session opens automatically for the debugger. If you have not yet saved any personal settings with regard to the layout of the debugger, the Editor tool will now appear on the left, with the Display Variables tool on the right.
    1. Select one of the three desktops in order to reconfigure it for debugging the Web Dynpro application (see Designing Work Areas).
    2. The right-hand edge of the debugger window has a bar of function icons. Choose the Replace Tools icon:
    3. In the next dialog box (New Tool) open the lowest node (Special Tools) and choose Web Dynpro.
    4. Confirm the dialog box.
    On the right of the debugger desktop, you will see that the previous tool has now been replaced by the Web Dynpro debugger. You can save this setting for future debugging activities. To do this, choose Save Layout In the debugger’s general toolbar.
    Thankyou,
    Ramganesh.

  • Maintain user session in web dynpro application

    Hello Experts,
    I have a web dynpro application. Whenever user presses F5 or refreshes the application, user is made available with login page. Instead, I want to maintain the session for that particular logged on user, so, whenever he refreshes he lands on the same page if his session is active.
    As far as I read some discussions on scn, I got to know that there is no such thing in WD ABAP. Still, is there any way to accomplish this type of requirement?
    PDN.
    Regards,
    Harsh

    Hi Harsh,
         My assumption of your requiremnt:
    The application is suppose to bypass SAP authentication and should prompt the user with a custom view .
    So when the user logs in using the custom view (input details), then user shouldnt be prompted with login screen again if he presses f5 .
    A very different requirement .. but may be you can try using a static flag which will be raised when you login using the custom view.
    This flag value can be used to determine if the user has logged in earlier during the session.
    Thanks & Regards,
    Tashi

  • How to customize error mess, when an Web Dynpro application Deployed

    Hi Frndz...
    When we r deploying any web dynpro application , if there was any error in that WDP application its showing an error page the list of errors with HOST name  n patch level n OS details n so many n with the line number of that error in the code.. Normally.
    But as my requirement i need to restrict the HOST,OS ,PATCH details in this list to avoid the security issues.
    If anybody have any idea plz share with  me...
    Regards
    Rajesh

    Hi..
    Thank u boss, ur reply was very helpfull to sort out our requirment.
    Regrads
    Rajesh

  • How to store text field data from web dynpro application in pcd ?

    Hi Forum,
    I am new to web Dynpro.
    I want to store user specific data (a text field value) from a wd application in PCD and access it every time the user runs the application.How can I achieve this?
    Thanks,
    Mickey.

    Hi
    I created the "read" and "update" methods in my application service. How can I call them? I created and implemented the methods just like here: https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/340fc0ea-0c01-0010-74bf-965b11031e77
    Operations:
    - readMyEntityService:
    - updateMyEntityService
    Implementation:
    retValue = getMyEntityService().read(key);
    getMyEntityService().update(dS0);
    In Web Dynpro there is this update method with the code above (in my original post).
    How can I call the update-method????????
    Kind regards
    Bettina

  • Error in tutotial "How to ...  Build a Web Dynpro Application"

    Hi,
    I deployed this tutorial in my WAS 6.40 and had the configuration in the SLD and in the Jco connection.
    When I tried to execute it I received the messages below:
    Error stacktrace:
    com.sap.tc.webdynpro.services.exceptions.WDTypeNotFoundException: type com.sap.demo.flightlist.model.types.Bapimaxrow could not be loaded: com.sap.dictionary.runtime.DdException: The logical dictionary com.sap.demo.flightlist.model.types.FlightListModel does not exist
         at com.sap.tc.webdynpro.services.datatypes.core.DataTypeBroker.getSimpleType(DataTypeBroker.java:242)
         at com.sap.tc.webdynpro.services.datatypes.core.DataTypeBroker.getDataType(DataTypeBroker.java:205)
         at com.sap.tc.webdynpro.progmodel.context.AttributeInfo.init(AttributeInfo.java:471)
         at com.sap.tc.webdynpro.progmodel.context.NodeInfo.initAttributes(NodeInfo.java:771)
         at com.sap.tc.webdynpro.progmodel.context.NodeInfo.init(NodeInfo.java:756)
         at com.sap.tc.webdynpro.progmodel.context.NodeInfo.init(NodeInfo.java:761)
         at com.sap.tc.webdynpro.progmodel.context.Context.init(Context.java:40)
         at com.sap.tc.webdynpro.progmodel.controller.Controller.init(Controller.java:199)
         at com.sap.tc.webdynpro.clientserver.cal.ClientComponent.init(ClientComponent.java:346)
         at com.sap.tc.webdynpro.clientserver.cal.ClientApplication.init(ClientApplication.java:352)
         at com.sap.tc.webdynpro.clientserver.task.Task.createApplication(Task.java:217)
         at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.execute(WebDynproMainTask.java:581)
         at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:58)
         at com.sap.tc.webdynpro.clientserver.cal.ClientManager.doProcessing(ClientManager.java:248)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doWebDynproProcessing(DispatcherServlet.java:154)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:116)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doGet(DispatcherServlet.java:48)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:385)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:263)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:339)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:317)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:810)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:238)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:147)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:37)
         at com.sap.engine.core.cluster.impl6.session.UnorderedChannel$MessageRunner.run(UnorderedChannel.java:71)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:94)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:162)
    Caused by: com.sap.dictionary.runtime.DdException: The logical dictionary com.sap.demo.flightlist.model.types.FlightListModel does not exist
         at com.sap.dictionary.runtime.DdDictionaryPool.getLogicalSystemName(DdDictionaryPool.java:109)
         at com.sap.dictionary.runtime.DdDictionaryPool.getDictionary(DdDictionaryPool.java:62)
         at com.sap.dictionary.runtime.DdDictionaryPool.getDictionary(DdDictionaryPool.java:39)
         at com.sap.dictionary.runtime.DdBroker.getDataType(DdBroker.java:149)
         at com.sap.dictionary.runtime.DdBroker.getSimpleType(DdBroker.java:170)
         at com.sap.tc.webdynpro.services.datatypes.core.DataTypeBroker.getSimpleType(DataTypeBroker.java:234)
         ... 32 more
    Important: I execute the tutorial "FlightBooking" and it is working well, and I'm using the same Jco specifications.

    Hi Flavio,
         It looks like your back end box does not have the type FlightListModel in it.  This can happen for any of a couple of reasons, the Metadata JCO connection could be wrong (but you indicate it is just fine), the back end function module and associated types may not exist on your back end system, or the metadata cache on the J2EE engine is filled with the wrong data (or is simply missing data).  If the first two are double checked and there is no problem, you might try restarting your J2EE engine which would re-load the metadata cache.
         Hope this helps,
            --Greg

  • Clearing Context in Web Dynpro applications

    Hi All,
    I am using a view that is called from multiple places based on different criteria. This view has a table that is fed from the custom controller. Some of the context data for this custom controller are being set from the other views.  I need to clear the resultset of the custom controller and retain the input data from the other views. Is there any simple way of clearing data in the context node?  I tried invalidating the node, context but nothing seems to work. Any suggestion what I might be doing wrong?
    Thanks and regards,
    Hemanth

    hi Hemanth,
    Where are u trying to invalidate the node. What is the exact scenario.If u want the custom controller to be updated in different views... u can say
        wdThis.wdGet<contr name>Controller().wdGetContext().node<name>().invalidate();
    in the init of the view where the value of the custom controller is updated.
    Is the problem with invalidate or with the updation in values.Invalidate will always work if u set the lead selection properly.
    If u cud elobarate more on the problem someone could really help u out...
    Regards
    Bharathwaj

  • [ADF custom task form] How to get logged user in Worklist app?

    Hi!
    How to get the user id, logged in Worklist application in a managed bean? I'm creating ADF task form for human task and i have to know which user is logged in.
    Thx!

    &lt;af:outputText value="Authenticated User: #{securityContext.userName}" id="ot2"/>
    or via standard j2se apis (Subject.getSubject(..))
    hth clemens (http://blogs.oracle.com/soabpm)

Maybe you are looking for