published by Yannick on 8 June, 2011 - 22:16
It often happens that you need to know the username from the user who has logged in into the portal. The JSR 168 and 286 standard dictates that the portal should pass this information to the portlet.
This snippet will show you how you can get the username:
Snippet:
If you are creating portlets with the ADF Portlet bridge you can use the ADFContext:
String user =
ADFContext.getCurrent().getSecurityContext().getUserName();
Otherwhise, you can get it from the PortletRequest:
FacesContext ctx = FacesContext.getCurrentInstance();
PortletRequest req =
(PortletRequest)ctx.getExternalContext().getRequest();
String user = req.getRemoteUser();
Comments
How to set userName from security context to Criteria in portlet
From the portal application I have to get the logged in user and use the same user to filter the records in Portlet. I have to execute a view Criteria in portlet as a default method activity which takes logged in user as a input param.
Is this achievable? Please let me know.
Thanks,
Shiva.
It's possible but the
It's possible but the explenation is quite large. Can you post this on the webcenter forum on otn so i can answer it there? It0s much better to ask such question there.
Hi Yannick,
Hi Yannick,
I have posted the question on webcenter forum. the below is the thread id.
https://forums.oracle.com/forums/thread.jspa?threadID=2272975&tstart=0
Thanks,
Is same possible with OmniPortlet?
Hello!
Is there any way to pass a user parameter in an OmniPortlet's SQL statement?
I have am omniportlet that sends a SQL statement and gets back data. It works. But I am trying to figure out how to pass a user parameter such as UserName.
Thanks!
The omniportlet is not a JSR
The omniportlet is not a JSR 168 or 286 portlet. Instead it is an Oracle PDK portlet which means that it's using different API's.
In you case I would recommend passing the username as a parameter to the omniportlet. While creating your query, you can then bind them to the username i nthe portal.
Add new comment