I wrote a portlet and added to liferay.
I have found the way to get user name from cookie: https://www.everit.biz/web/guest/blog/-/blogs/getting-current-liferay-user-in-a-standalone-webapp?_33_redirect=/web/guest/blog
I have looked into the zk liferay package, there is just JQuery related classes. http://www.zkoss.org/javadoc/6.0.0/zk/org/zkoss/zkplus/liferay/package-summary.html
Is there any way to get the current user in ZK?
Follow simple pattern
In the main Entry controller class, the class which extends the DHtmlLayoutPortlet
In the process method you can setup commonParameter of liferay to zk-session
I am providing you code snippet :
@Override
protected boolean process(Session sess, RenderRequest request,
RenderResponse response, String path, boolean bRichlet)
throws PortletException, IOException {
setupSessionParameters(sess, request);
return super.process(sess, request, response, path, bRichlet);
}
protected void setupSessionParameters(Session sess, RenderRequest request) {
ThemeDisplay themeDisplay = (ThemeDisplay) request.getAttribute(WebKeys.THEME_DISPLAY);
PortletSession portletSession = request.getPortletSession();
PortletPreferences prefs = request.getPreferences();
sess.setAttribute("SESSION_ID", portletSession.getId());
sess.setAttribute("THEME_DISPLAY", themeDisplay);
sess.setAttribute("GROUP_ID", themeDisplay.getScopeGroupId());
sess.setAttribute("PORTLET_PREFERENCES", prefs);
sess.setAttribute("PORTLET_ID", themeDisplay.getPortletDisplay().getId());
sess.setAttribute("currentUser", themeDisplay.getUser().getScreenName());
}
Use that zk session for getting those parameters in your application
If you want more information
It has all information that you want ...:)