<?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>Programmatically asign Display Page to JournalArticle</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=112742211" />
  <subtitle>Programmatically asign Display Page to JournalArticle</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=112742211</id>
  <updated>2026-04-05T13:45:45Z</updated>
  <dc:date>2026-04-05T13:45:45Z</dc:date>
  <entry>
    <title>RE: Programmatically asign Display Page to JournalArticle</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112764838" />
    <author>
      <name>Christoph Rabel</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112764838</id>
    <updated>2019-03-14T18:25:56Z</updated>
    <published>2019-03-14T18:25:56Z</published>
    <summary type="html">I think, the answer of Chema is correct, I checked the sourcecode of the JournalPortlet, see _updateAssetDisplayPage:&lt;br /&gt;&lt;br /&gt;https://github.com/liferay/liferay-portal/blob/7.2.x/modules/apps/journal/journal-web/src/main/java/com/liferay/journal/web/internal/portlet/JournalPortlet.java&lt;br /&gt;&lt;br /&gt;Btw.: Good to know that this has changed. I think we did something similar as you do. JournalArticleLocalServiceWrapper + &amp;#34;fix&amp;#34; the displaypage for news entries. And some day in the future, we will migrate that to 7.2 or so ...</summary>
    <dc:creator>Christoph Rabel</dc:creator>
    <dc:date>2019-03-14T18:25:56Z</dc:date>
  </entry>
  <entry>
    <title>RE: Programmatically asign Display Page to JournalArticle</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112759514" />
    <author>
      <name>Tom Aerts</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112759514</id>
    <updated>2019-03-14T15:37:59Z</updated>
    <published>2019-03-14T15:37:59Z</published>
    <summary type="html">That did it, thanks!</summary>
    <dc:creator>Tom Aerts</dc:creator>
    <dc:date>2019-03-14T15:37:59Z</dc:date>
  </entry>
  <entry>
    <title>RE: Programmatically asign Display Page to JournalArticle</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112759096" />
    <author>
      <name>Chema Balsas</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112759096</id>
    <updated>2019-03-14T15:07:01Z</updated>
    <published>2019-03-14T15:07:01Z</published>
    <summary type="html">Got it, maybe I didn&amp;#39;t fully understand. Another more classic approach can be found in the &lt;a href="https://github.com/liferay/liferay-portal/blob/master/modules/apps/frontend-theme-porygon/frontend-theme-porygon-site-initializer/src/main/java/com/liferay/frontend/theme/porygon/site/initializer/internal/PorygonSiteInitializer.java"&gt;PorygonSiteInitializer&lt;/a&gt;. Just in case that provides any clues.</summary>
    <dc:creator>Chema Balsas</dc:creator>
    <dc:date>2019-03-14T15:07:01Z</dc:date>
  </entry>
  <entry>
    <title>RE: Programmatically asign Display Page to JournalArticle</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112757753" />
    <author>
      <name>Tom Aerts</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112757753</id>
    <updated>2019-03-14T14:58:44Z</updated>
    <published>2019-03-14T14:58:44Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;Tried this already and doesn't seem to have any effect:&lt;br&gt;&lt;br&gt;(excuse the messy code, just throwing stuff at the groovy tab)&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;code&gt;&amp;amp;nbsp; locale = LocaleUtil.getSiteDefault()
&amp;amp;nbsp; group = GroupLocalServiceUtil.search(PortalUtil.getDefaultCompanyId(), null, "Liferay DXP", null, null, false, 0, 1).get(0);

&amp;amp;nbsp;items =JournalArticleLocalServiceUtil.getStructureArticles(group.getGroupId(),"NIEUWS")

&amp;amp;nbsp;item =items.get(5) // &amp;amp;lt;-- article with display page set
&amp;amp;nbsp;jul = items.get(35) // &amp;amp;lt;-- article with display page not set
lay = item.getLayout()

jul.setLayoutUuid(lay.getUuid())
jul.persist()
&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;results in &lt;pre&gt;&lt;code&gt;Title: Jobevent IT op komst 
getLayout(): 
{mvccVersion=29, uuid=638086dc-28b2-bbd2-8834-01273b98d44e, plid=118492, groupId=20126, companyId=20099, userId=37820, userName=Tom Aerts, 
createDate=Fri Jan 04 09:12:38 GMT 2019, modifiedDate=Tue Mar 12 15:39:33 GMT 2019, privateLayout=false, layoutId=22, parentLayoutId=1, 
name=NieuwsBericht, title=, description=, keywords=, robots=, type=portlet, typeSettings=CUSTOMIZABLE_LAYOUT=false
addToAutoMenus=on
column-1=com_liferay_asset_publisher_web_portlet_AssetPublisherPortlet_INSTANCE_BATVWdSe2Vrv,com_liferay_asset_publisher_web_portlet_RelatedAssetsPortlet_INSTANCE_TO6uXDgeDSTz
column-1-customizable=false
column-2=wieiswieportlet_INSTANCE_KvFn2ihDhNXf,menuportlet_INSTANCE_TawcY5OvKGn4,delijn_INSTANCE_1b1UECnPLrLY
column-2-customizable=false
default-asset-publisher-portlet-id=com_liferay_asset_publisher_web_portlet_AssetPublisherPortlet_INSTANCE_BATVWdSe2Vrv
layout-template-id=2_columns_iii
layoutUpdateable=true
sitemap-changefreq=daily
sitemap-include=1
, hidden=false, friendlyURL=/nieuwsbericht, iconImageId=0, themeId=classic_WAR_classictheme, colorSchemeId=, css=, priority=1, 
layoutPrototypeUuid=, layoutPrototypeLinkEnabled=false, sourcePrototypeLayoutUuid=, lastPublishDate=null}&lt;/code&gt;&lt;/pre&gt;&lt;br&gt;Which is the "page" i want (/nieuwsbericht, with default-asset-publisher etc set). No result however:&lt;br&gt;&lt;br&gt;&lt;img src="https://i.imgur.com/cGBzVUw.png" height="162" width="676"&gt;&lt;br&gt;&lt;br&gt;&lt;br&gt;Unrelated: tried JournalArticleLocalServiceUtil.updateJournalArticle(jul) as well, It won't run however, because jul is of type 'JournalArticleImpl'.. confusing&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Tom Aerts</dc:creator>
    <dc:date>2019-03-14T14:58:44Z</dc:date>
  </entry>
  <entry>
    <title>RE: Programmatically asign Display Page to JournalArticle</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112754594" />
    <author>
      <name>Christoph Rabel</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112754594</id>
    <updated>2019-03-14T13:22:32Z</updated>
    <published>2019-03-14T13:22:32Z</published>
    <summary type="html">I am not sure which version you use, but at least in 7.0 you can set the layoutUuid to the page uuid.&lt;br /&gt;&lt;br /&gt;Basically you would write something like (pseudocode)&lt;br /&gt;&lt;br /&gt;  Layout layout = layoutlocalservice.getLayout(...);&lt;br /&gt;  String uuid = layout.getLayoutUUID();&lt;br /&gt;  journalarticle.setLayoutUuid(uuid);&lt;br /&gt;  journalarticle.persist();</summary>
    <dc:creator>Christoph Rabel</dc:creator>
    <dc:date>2019-03-14T13:22:32Z</dc:date>
  </entry>
  <entry>
    <title>RE: Programmatically asign Display Page to JournalArticle</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112753911" />
    <author>
      <name>Tom Aerts</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112753911</id>
    <updated>2019-03-14T12:50:42Z</updated>
    <published>2019-03-14T12:50:42Z</published>
    <summary type="html">LayoutPageTemplateEntry seems specific for Fragment based display pages (I&amp;#39;m using a regular page with default asset publisher); I&amp;#39;ll have a look though, might give some new clues, thanks</summary>
    <dc:creator>Tom Aerts</dc:creator>
    <dc:date>2019-03-14T12:50:42Z</dc:date>
  </entry>
  <entry>
    <title>RE: Programmatically asign Display Page to JournalArticle</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112753574" />
    <author>
      <name>Chema Balsas</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112753574</id>
    <updated>2019-03-14T12:40:28Z</updated>
    <published>2019-03-14T12:40:28Z</published>
    <summary type="html">Not sure if this helps, but in the Porygon theme we set a default Display Page for a ddm structure. Maybe that can give you some hints.&lt;br /&gt;&lt;br /&gt;Look at &lt;a href="https://github.com/liferay/liferay-portal/blob/master/modules/apps/frontend-theme-porygon/frontend-theme-porygon-site-initializer/src/main/java/com/liferay/frontend/theme/porygon/site/initializer/internal/PorygonSiteInitializer.java#L255-L288"&gt;_addDisplayPageEntry&lt;/a&gt; in the &lt;a href="https://github.com/liferay/liferay-portal/blob/master/modules/apps/frontend-theme-porygon/frontend-theme-porygon-site-initializer/src/main/java/com/liferay/frontend/theme/porygon/site/initializer/internal/PorygonSiteInitializer.java"&gt;PorygonSiteInitializer&lt;/a&gt;</summary>
    <dc:creator>Chema Balsas</dc:creator>
    <dc:date>2019-03-14T12:40:28Z</dc:date>
  </entry>
  <entry>
    <title>Programmatically asign Display Page to JournalArticle</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112742210" />
    <author>
      <name>Tom Aerts</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=112742210</id>
    <updated>2019-03-14T09:23:54Z</updated>
    <published>2019-03-14T09:23:54Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;I'm creating an interface to create JournalArticles with a custom (global) structure. I can't set a default display page for this structure, as it's site dependant.&lt;br&gt;Trying to figure out how I can set the display page. &lt;br&gt;I noticed JournalArticle's .getLayout() (on an article with the display page set correctly) seems to represent it (partially at least), but setLayoutUuid() + persist() don't seem to have any effect (at all).&lt;br&gt;&lt;br&gt;Ideally I'm looking for a method to set a JournalArticle's display page from an url (e.g. a custom setDisplayPage(JournalArticle j, String url) method), though just getting the display page from another - correctly configured - JournalArticle and going from there would be perfectly workable as well (e.g. setDisplayPage(JournalArticle correctly_configured_article, JournalArticle new_article) )&lt;br&gt;&lt;br&gt;I'm assuming the class AssetDisplayPageEntry will have to be used, but despite all my digging I can't figure it out. Just some pointers in the right direction should be fine, though code snippets are always welcome :-)&amp;nbsp;&lt;br&gt;&lt;br&gt;thanks in advance!&lt;br&gt;&lt;br&gt;&lt;strong&gt;Solution:&lt;br&gt;&lt;/strong&gt;Adding the correct Layout to the JournalArticle isn't enough. &lt;br&gt;an AssetDisplayPageEntry needs to be created as well:&lt;pre&gt;&lt;code&gt;JournalArticle article = &lt;/code&gt;&lt;article that needs the display page&gt;&lt;code&gt;
userid = &amp;lt;acquire some userid&amp;gt;
groupid = &amp;lt;acquire relevant site's groupid&amp;gt;
cnameid = PortalUtil.getClassNameId(JournalArticle.class)
context = new ServiceContext()

AssetDisplayPageEntryLocalServiceUtil.addAssetDisplayPageEntry(userid, groupid, cnameid, article.getResourcePrimKey(), AssetDisplayPageConstants.TYPE_SPECIFIC, context)
&amp;lt;/acquire&amp;gt;&amp;lt;/acquire&amp;gt;&lt;/code&gt;&lt;/article&gt;&lt;/pre&gt;&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Tom Aerts</dc:creator>
    <dc:date>2019-03-14T09:23:54Z</dc:date>
  </entry>
</feed>
