<?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>Access Liferay-JavaScript-Object in React-Portlet</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=119200323" />
  <subtitle>Access Liferay-JavaScript-Object in React-Portlet</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=119200323</id>
  <updated>2026-04-04T03:37:02Z</updated>
  <dc:date>2026-04-04T03:37:02Z</dc:date>
  <entry>
    <title>RE: Access Liferay-JavaScript-Object in React-Portlet</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=119250962" />
    <author>
      <name>Fernando Fernandez</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=119250962</id>
    <updated>2020-05-27T13:40:52Z</updated>
    <published>2020-05-27T13:40:52Z</published>
    <summary type="html">Didn&amp;#39;t try those, sorry.</summary>
    <dc:creator>Fernando Fernandez</dc:creator>
    <dc:date>2020-05-27T13:40:52Z</dc:date>
  </entry>
  <entry>
    <title>RE: Access Liferay-JavaScript-Object in React-Portlet</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=119252684" />
    <author>
      <name>Fredi B</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=119252684</id>
    <updated>2020-05-27T08:41:35Z</updated>
    <published>2020-05-27T08:41:35Z</published>
    <summary type="html">Hi Fernando,&lt;br /&gt;are you using this approach with &amp;#34;adapted React-Applications&amp;#34;?&lt;br /&gt;Because I am only able to get this working by creating a Liferay-React-Application and not when adapting a already existing React App. </summary>
    <dc:creator>Fredi B</dc:creator>
    <dc:date>2020-05-27T08:41:35Z</dc:date>
  </entry>
  <entry>
    <title>RE: Access Liferay-JavaScript-Object in React-Portlet</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=119237164" />
    <author>
      <name>Fernando Fernandez</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=119237164</id>
    <updated>2020-05-26T15:22:24Z</updated>
    <published>2020-05-26T15:22:24Z</published>
    <summary type="html">&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;We have been using the Liferay javascript object in 7.2 CE React portlets without any difficulty and simply invoking it on any&amp;nbsp;&amp;nbsp;javascript method/function.&lt;br&gt;&lt;br&gt;&lt;pre&gt;&lt;code&gt;

import React from 'react';
import ReactDOM from 'react-dom';

import SearchComponent from './SearchComponent';


/**
 * This is the main entry point of the portlet.
 *
 * See https://tinyurl.com/js-ext-portlet-entry-point for the most recent 
 * information on the signature of this function.
 *
 * @param  {Object} params a hash with values of interest to the portlet
 * @return {void}
 */
export default function main({portletNamespace, contextPath, portletElementId}) {
    Liferay.Service(
        '/cust.customer/get-customers',
        {
          start: -1,
          end: -1
        },
        function(custList) {
          console.log("ajax returned:",custList);
          ReactDOM.render(
            &amp;lt;searchcomponent portletNamespace="{portletNamespace}" contextPath="{contextPath}" portletElementId="{portletElementId}" custList="{custList}" /&amp;gt;, 
            document.getElementById(portletElementId)
        );
        }
      );
}
&lt;/code&gt;&lt;/pre&gt;&lt;/body&gt;&lt;/html&gt;</summary>
    <dc:creator>Fernando Fernandez</dc:creator>
    <dc:date>2020-05-26T15:22:24Z</dc:date>
  </entry>
  <entry>
    <title>RE: Access Liferay-JavaScript-Object in React-Portlet</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=119200700" />
    <author>
      <name>Fredi B</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=119200700</id>
    <updated>2020-05-20T13:58:37Z</updated>
    <published>2020-05-20T13:58:37Z</published>
    <summary type="html">Whoops, &lt;br /&gt;I guess I found (atleast one) solution.&lt;br /&gt;&lt;blockquote&gt; componentDidMount() { &lt;br /&gt;       let liferay = window[&amp;#39;Liferay&amp;#39;]; &lt;br /&gt;       console.log(liferay);     &lt;br /&gt;}&lt;br /&gt;&lt;/blockquote&gt;&lt;br /&gt;Are there any other ways? &lt;br /&gt;Maybe also a solution how to easily access the fields of the configuration created with configuration.json?&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt;&amp;#34;portletInstance&amp;#34;: {        &lt;br /&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&amp;#34;fields&amp;#34;: {            &lt;br /&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&amp;#34;Position&amp;#34;: {                &lt;br /&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&amp;#34;type&amp;#34;: &amp;#34;string&amp;#34;,                &lt;br /&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&amp;#34;name&amp;#34;: &amp;#34;Position&amp;#34;,                &lt;br /&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&amp;#34;description&amp;#34;: &amp;#34;Position of Text&amp;#34;,               &lt;br /&gt;&lt;/blockquote&gt;&lt;blockquote&gt; &amp;#34;default&amp;#34;: &amp;#34;center&amp;#34;,                &lt;br /&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&amp;#34;options&amp;#34;: {                   &lt;br /&gt;&lt;/blockquote&gt;&lt;blockquote&gt; &amp;#34;left&amp;#34;: &amp;#34;left&amp;#34;,                    &lt;br /&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&amp;#34;center&amp;#34;: &amp;#34;center&amp;#34;,                    &lt;br /&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&amp;#34;right&amp;#34;: &amp;#34;right&amp;#34;                &lt;br /&gt;&lt;/blockquote&gt;&lt;blockquote&gt;}           &lt;br /&gt;&lt;/blockquote&gt;&lt;blockquote&gt; },&lt;/blockquote&gt;</summary>
    <dc:creator>Fredi B</dc:creator>
    <dc:date>2020-05-20T13:58:37Z</dc:date>
  </entry>
  <entry>
    <title>Access Liferay-JavaScript-Object in React-Portlet</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=119200322" />
    <author>
      <name>Fredi B</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=119200322</id>
    <updated>2020-05-20T13:17:27Z</updated>
    <published>2020-05-20T13:17:27Z</published>
    <summary type="html">Hello Liferay-Community,&lt;br /&gt;is there some way to get access to the &amp;#34;Liferay-Object&amp;#34; in an only to Liferay adapted Create-React-App?&lt;br /&gt;I want to access things like the authKey or Language-Keys  in my React Portlet.&lt;br /&gt;​​​​​​​&lt;br /&gt;For example: Liferay.Language.get(&amp;#39;portlet-namespace&amp;#39;)&lt;br /&gt;&lt;br /&gt;Thank you and Happy Fathers-Day tomorrow to all Fathers,&lt;br /&gt;Fredi</summary>
    <dc:creator>Fredi B</dc:creator>
    <dc:date>2020-05-20T13:17:27Z</dc:date>
  </entry>
</feed>
