<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>How can a portlet on a display page find what asset is being displayed?</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=121348426" />
  <subtitle>How can a portlet on a display page find what asset is being displayed?</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=121348426</id>
  <updated>2026-06-02T19:10:34Z</updated>
  <dc:date>2026-06-02T19:10:34Z</dc:date>
  <entry>
    <title>RE: RE: How can a portlet on a display page find what asset is being displa</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121353532" />
    <author>
      <name>Russell Bohl</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121353532</id>
    <updated>2022-02-07T14:21:25Z</updated>
    <published>2022-02-07T14:21:25Z</published>
    <summary type="html">&lt;p&gt;Great! Glad you got it solved in an even more robust way.&lt;/p&gt;</summary>
    <dc:creator>Russell Bohl</dc:creator>
    <dc:date>2022-02-07T14:21:25Z</dc:date>
  </entry>
  <entry>
    <title>RE: RE: How can a portlet on a display page find what asset is being displa</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121350458" />
    <author>
      <name>Fernando Fernandez</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121350458</id>
    <updated>2022-02-04T12:41:59Z</updated>
    <published>2022-02-04T12:41:58Z</published>
    <summary type="html">&lt;p&gt;Hi Russell,&lt;/p&gt;
&lt;p&gt;I always come here to post my questions, before I go to Slack,
  because answers in Slack are not easily found by others. :-)   In this
  case, I though this post didn't go ahead, because I was getting an
  error when posting, so I went to Slack instead.&lt;/p&gt;
&lt;p&gt;Meanwhile, looking at the source code
  of RelatedAssetsInfoCollectionProvider.java, I got the answer I really needed. &lt;/p&gt;
&lt;p&gt;While Vitaly's answer is quite usable, if you're working in Java you
  can use the API to find the assetId with this code:&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;pre&gt;
&lt;code class="language-java"&gt;	private long _getLayoutAssetEntryId() {
		ServiceContext serviceContext =
			ServiceContextThreadLocal.getServiceContext();

		HttpServletRequest httpServletRequest = serviceContext.getRequest();

		AssetEntry layoutAssetEntry =
			(AssetEntry)httpServletRequest.getAttribute(
				WebKeys.LAYOUT_ASSET_ENTRY);

		if (layoutAssetEntry != null) {
			return layoutAssetEntry.getEntryId();
		}

		return 0;
	}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Fernando&lt;/p&gt;</summary>
    <dc:creator>Fernando Fernandez</dc:creator>
    <dc:date>2022-02-04T12:41:58Z</dc:date>
  </entry>
  <entry>
    <title>RE: How can a portlet on a display page find what asset is being displayed?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121348616" />
    <author>
      <name>Russell Bohl</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121348616</id>
    <updated>2022-02-01T14:13:44Z</updated>
    <published>2022-02-01T14:13:43Z</published>
    <summary type="html">&lt;p&gt;Hi Fernando, I can see that you received an answer in &lt;a
  href="https://liferay-community.slack.com/archives/C5H30KZ1A/p1643715397315599"&gt;slack&lt;/a&gt;.
  I'm not sure if we have a policy about posting in both places, but
  it's probably best to at least link to the other context if you do
  post in both.&lt;/p&gt;
&lt;p&gt;By the way, when I saw the answer in slack it struck me as brittle.
  I'd hope ther was an API or utilities to get or construct the URL. But
  I don't know so I can't give you a good answer on it.&lt;/p&gt;</summary>
    <dc:creator>Russell Bohl</dc:creator>
    <dc:date>2022-02-01T14:13:43Z</dc:date>
  </entry>
  <entry>
    <title>How can a portlet on a display page find what asset is being displayed?</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121348425" />
    <author>
      <name>Fernando Fernandez</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121348425</id>
    <updated>2022-02-01T11:29:52Z</updated>
    <published>2022-02-01T11:29:51Z</published>
    <summary type="html">&lt;p&gt;Hi all,&lt;/p&gt;
&lt;p&gt;I'm sure there's a fast&amp;amp;simple way way to do this, but I'm not
  seeing it...&lt;/p&gt;
&lt;p&gt;I'd like to put a portlet on a display page, which is not initially
  bound to a certain webcontent.&lt;/p&gt;
&lt;p&gt;At runtime, I'd like my portlet to find out what webcontent is being
  displayed and work that info.&lt;/p&gt;
&lt;p&gt;How can a portlet find out what asset/web content is being shown by
  the display page template?&lt;/p&gt;
&lt;p&gt;TIA&lt;/p&gt;
&lt;p&gt;Fernando&lt;/p&gt;</summary>
    <dc:creator>Fernando Fernandez</dc:creator>
    <dc:date>2022-02-01T11:29:51Z</dc:date>
  </entry>
</feed>
