Display entry from mysql databaseDisplay entry from mysql databasehttps://liferay.dev/en/c/message_boards/find_thread?p_l_id=119785333&threadId=1210673712024-03-29T00:09:17Z2024-03-29T00:09:17ZRE: RE: Display entry from mysql databaseRussell Bohlhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1210797332021-08-27T17:19:46Z2021-08-27T17:19:45Z<p>Hi Reiner, I still don't know if I have enough understanding of the
situation, but I'm closer now. I'm going to tell you what I think I
know about your situation, and you can correct anything that is wrong.</p>
<p> </p>
<ul>
<li>You are working with a service builder entity that you developed,
not one of Liferay's entities.</li>
<li>In addition to a portlet that calls your service builder services,
there's another tool that adds entities to the database.</li>
<li>Your service builder backed portlet works as expected: when you
add an entity through the portlet, the render phase is called after
the entity is added, so the new entity displays properly in the
portlet's search container.</li>
<li>However, when the other tool adds entities to the database, the
render phase is not invoked, so the new entities are not reflected
in the search container.</li>
<li>If you refresh the page, the render phase is invoked, the entity
list is re-fetched form the DB, and all the entities show up as expected.</li>
<li>Your question then is about how you can avoid refreshing the page
to display the new entities.</li></ul>
<p>If that's all accurate, I'm afraid I am at a loss. One idea that may
or may not work would be to </p>
<p>1. Create a model listener for your model, probably listening via the
onAfterCreate method, but see the <a
href="https://docs.liferay.com/dxp/portal/7.2-latest/javadocs/portal-kernel/com/liferay/portal/kernel/model/BaseModelListener.html">javadoc
for BaseModelListener</a> for a list of the events. See the <a
href="https://learn.liferay.com/dxp/latest/en/liferay-internals/extending-liferay/creating-a-model-listener.html#identify-a-model-class-and-event">Creating
a Model Listener article</a> to quickly get up and running with a
Model Listener.</p>
<p>2. In the ModelListener, invoke the render method of the portlet. I
don't know if this will work or not.<br /> </p>Russell Bohl2021-08-27T17:19:45ZRE: RE: Display entry from mysql databaseReiner Zufallhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1210762342021-08-26T12:10:24Z2021-08-26T12:10:23Z<p>Hi Russell</p>
<p>thank your for your answer,</p>
<p>we use two ways to write values into the database. The first is
liferay with its servicebuilder and the second is another software,
which writes directly into the same database table, but the software
does not use any of the liferay services.</p>
<p>What we want is, when the other software writes directly into the
database, liferay only display this entity. It works, but only when
pressing a button, which executes a action request to refresh the
database tables.</p>
<p>is there a way, where liferay recognize changes into the database and
refresh it without pressing a button.</p>
<p> </p>Reiner Zufall2021-08-26T12:10:23ZRE: Display entry from mysql databaseOlaf Kockhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1210733172021-08-25T12:15:12Z2021-08-25T12:15:11Z<p>Given the other article you linked and your original question:</p>
<ul>
<li>If there's any overlap with Liferay's entities (e.g. through
primary keys generated by CounterLocalService), you'll need to cater
for this and reserve a certain number of keys. Otherwise yes, you'll
get duplicate keys and mess up your database</li>
<li>an ActionRequest has nothing to do with any database data. Please
specify (preferably with simplified code, or database snippets, what
your situation is on the database side and how you actually enter
data (so far you only tell us how you <em>don't</em> enter data,
which is not useful)</li>
<li>Liferay's SearchContainer is best used with Liferay Entities (but
probably can be used with other entities as well), so you'll need to
really be sure you're generating the ids of the entities in a proper
way that can be interpreted by the portal.</li></ul>Olaf Kock2021-08-25T12:15:11ZRE: RE: Display entry from mysql databaseRussell Bohlhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1210732582021-08-25T12:04:18Z2021-08-25T12:04:18Z<p>Hi Reiner, I understand a bit better now, skimming that old thread. I
guess when you say "written directly into the database, not using
liferays actionrequest" you also mean that you're not using
Liferay's services. Liferay entities should really be written to the
DB only using the services. But, can you clarify a few things (see below):</p>
<p>Are we talking about a Liferay entity or a custom entity? Are you
importing Users like the OP of the linked thread?</p>
<p>If a custom entitty, is it a Service Builder entity?</p>
<p>If it's a Liferay entity, are you writing an app with search
container code to display the entities, or are you trying to see the
imported objects in the native Liferay UI?</p>Russell Bohl2021-08-25T12:04:18ZRE: RE: Display entry from mysql databaseReiner Zufallhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1210722692021-08-25T05:41:36Z2021-08-25T05:41:36Z<p>Thank you for your answer,</p>
<p>Sry my english is bad.</p>
<p>No not this, i mean something other like this: <a href="https://liferay.dev/ask/questions/development/re-data-imported-directly-to-the-mysql-db-don-t-show-up-on-liferay-7">https://liferay.dev/ask/questions/development/re-data-imported-directly-to-the-mysql-db-don-t-show-up-on-liferay-7</a></p>
<p>is there a way to do this in liferay 7.2.1?</p>Reiner Zufall2021-08-25T05:41:36ZRE: Display entry from mysql databaseRussell Bohlhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1210710932021-08-24T17:39:06Z2021-08-24T17:38:31Z<pre>
<code class="language-java"><liferay-ui:search-container-results
results="<%= JournalArticleLocalServiceUtil.getArticles(groupId, articleId, searchContainer.getStart(), searchContainer.getEnd(), new ArticleVersionComparator()) %>"
/>
</code></pre>
<p>I may be misunderstanding. You can fetch Liferay entities into a
search container by calling their services, just like the above
snippet demonstrates. Your own custom entities acan be fetched in the
same way if you used Service Builder.</p>
<p> </p>Russell Bohl2021-08-24T17:38:31ZDisplay entry from mysql databaseReiner Zufallhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1210670702021-08-23T10:45:46Z2021-08-23T10:45:46Z<p>Hello there<br />