Legacy Knowledge Base
Published Jul. 2, 2025

How to access User object when overriding user-portrait taglib

Written By

Antonio Ortega

How To articles are not official guidelines or officially supported documentation. They are community-contributed content and may not always reflect the latest updates to Liferay DXP. We welcome your feedback to improve How To articles!

While we make every effort to ensure this Knowledge Base is accurate, it may not always reflect the most recent updates or official guidelines.We appreciate your understanding and encourage you to reach out with any feedback or concerns.

Legacy Article

You are viewing an article from our legacy "FastTrack" publication program, made available for informational purposes. Articles in this program were published without a requirement for independent editing or verification and are provided"as is" without guarantee.

Before using any information from this article, independently verify its suitability for your situation and project.

Issue

  • In Liferay Portal 6.x we made use of user-display taglib in order to show current user's image on screen. However, in Liferay DXP 7.x we are using user-portrait taglib, which actually includes a page.jsp.readme file in order to help being overriden. How can we access User object from this taglib so we can retrieve user's information?

Environment

  • Liferay DXP (Any version)

Resolution

  • Due to security and performance reasons the way to access to that information have been modified in Liferay DXP. In order to retrieve user's information, you can rename page.jsp.readme file removing .readme suffix and adding below code:
<%@ page import="com.liferay.taglib.ui.UserPortraitTag" %>
<%@ page import="com.liferay.portal.kernel.bean.BeanPropertiesUtil" %>
<%@ page import="com.liferay.portal.kernel.model.User" %>

<%
Object userPortraitTag = request.getAttribute(UserPortraitTag.class.getName());

User userDisplay = (User) BeanPropertiesUtil.getObject(userPortraitTag, "user");
%>
  • Once there, you can access userDisplay's information to work with it.
Did this article resolve your issue ?

Legacy Knowledge Base