hi
i tried create a web dynpro project, and access uwl, like the document
Accessing UWL Notifications from Web Dynpro Using UWL API
but doesn't matter i tried
IUser loggedinuser = UMFactory.getLogonAuthenticator().getLoggedInUser();
or
IUser loggedinuser = WDClientUser.getCurrentUser().getSAPUser();
it always hit UWLException: (Default) Logged in users context or session doesn't exist
my code like follows:
public void getInbox() { IWDMessageManager messageManager = wdComponentAPI.getMessageManager(); wdContext.nodeInboxData().invalidate(); try { IUWLService uwlService = (IUWLService) WDPortalUtils.getServiceReference(IUWLService.ALIAS_KEY);// PortalRuntime.getRuntimeResources().getService(IUWLService.ALIAS_KEY);// UWLContext uwlContext = new UWLContext(); IUser loggedinuser =UMFactory.getLogonAuthenticator().getLoggedInUser(); uwlContext.setAllowBackEndConnections(true); uwlContext.setUser(loggedinuser); uwlContext.setLocale(loggedinuser.getLocale()); IUWLSession uwlSession = uwlService.beginSession(uwlContext, 600); uwlContext.setSession(uwlSession); IUWLItemManager itemManager = uwlService.getItemManager(uwlContext); QueryResult result = itemManager.getItemsForItemType(uwlContext, ItemType.UWL_ITEM_NOTIFICATION, null, null); ItemCollection coll = result.getItems(); List l = coll.list(); Iterator iter = l.iterator(); while (iter.hasNext()) { Item item = (Item) iter.next(); if (item.getExternalType().equals("UWLNotification") && !item.getStatus().equals(StatusEnum.COMPLETED)) { IPrivateMyToDoCompView.IInboxDataElement data = wdContext.nodeInboxData().createInboxDataElement(); data.setItem(item); data.setSubject(item.getSubject()); data.setDescription(item.getDescription()); data.setStatus(item.getStatus().getText()); data.setCreatorId(item.getCreatorId()); data.setCreatedDate(item.getCreatedDate().toString()); wdContext.nodeInboxData().addElement(data); } } uwlService.endSession(uwlContext); } catch (Exception e) { e.printStackTrace(); messageManager.reportException(" Cause:" + e.getCause() + "\n Message:" + e.getMessage()); } }
can any one tell me why? and i develop with nwce 7.1 ehp1.
thank you