留言板

LR7: New Asset, Service Builder & Rendering

Menno Van Diermen,修改在6 年前。

LR7: New Asset, Service Builder & Rendering

New Member 发布: 1 加入日期: 17-5-5 最近的帖子
With regard to the Asset Framework, so far I have a Service Builder project implementation that seems successful, giving me *-api.jar and *-service.jar.
I've been able to use the *-api project as a dependency for a small tool to populate Liferay's database with instances of this Asset.
The Entry is visible as well in Server Administration and reindexable.
However, I am not able to access it as a type in the asset publisher, nor am I able to search the 10000+ entries that I've confirmed are in the portal's MySQL Database (and confirmed they are indexed into Elasticsearch, and searchable there). When searching in Liferay none of them appear.
Is this expected?

The documentation is contradictory:
'Once you have your asset added to the framework, Liferay Portal can render the asset by default using the Asset Publisher application.'
(Rendering an Asset)
vs
'Important: In order for Liferay’s Asset Publisher application to show your entity, the entity must have an Asset Renderer.'
(Adding, Updating and Deleting Assets for Custom Entities)

I figured this might be because of a lack of an AssetRenderer+-Factory, so I followed the Rendering an Asset tutorial,
Using Maven, I built a portlet from the com.liferay.project.templates.mvc.portlet archetype, but it is built as a .jar file. Is this correct?
I'm still working on fixing up the portlet to a workable state (taglib issues) but my main question is:
So far, is this expected behavior?
Is there any default rendering functionality or do I need the portlet with an AssetRenderer before it will show up anywhere?

Thanks very much.
thumbnail
David H Nebinger,修改在6 年前。

RE: LR7: New Asset, Service Builder & Rendering

Liferay Legend 帖子: 14916 加入日期: 06-9-2 最近的帖子
Menno Van Diermen:
Is this expected?


If you don't have the asset renderer, the AP will neither search nor display your assets. It just doesn't know how to display your asset without the renderer to take care of the HTML fragment.

The documentation is contradictory:
'Once you have your asset added to the framework, Liferay Portal can render the asset by default using the Asset Publisher application.'
(Rendering an Asset)
vs
'Important: In order for Liferay’s Asset Publisher application to show your entity, the entity must have an Asset Renderer.'
(Adding, Updating and Deleting Assets for Custom Entities)


Yeah, that contradiction is not intentional obviously. I think that depending upon how you interpret "asset added to the framework" makes all the difference. If you interpret that as "once you have added the asset columns to the entity, included necessary logic to the service persistence methods and implemented the asset renderer" as "added to the framework", then the rest of the sentence is accurate. If you interpret it as anything less, the sentence is contradictory.

Using Maven, I built a portlet from the com.liferay.project.templates.mvc.portlet archetype, but it is built as a .jar file. Is this correct?


In Liferay 7 CE / Liferay DXP, yes it will be a jar.

So far, is this expected behavior? Is there any default rendering functionality or do I need the portlet with an AssetRenderer before it will show up anywhere?


Yes this is the expected behavior. No, there is no default rendering functionality.

And this makes sense once you peel back the layers. If I create an entity for a school web site, Course, I can guess at the fields that would be included such as a description, a location, an instructor, ...

But what, exactly, should the asset framework do to render this as an HTML fragment in the AP? It wouldn't know what to include, what is a link, etc.

The Asset Renderer provides that bridge. It knows how to build the HTML fragment for the Course, and the asset framework knows how to find and use the renderer to display the asset in the AP and in search results.







Come meet me at the 2017 LSNA!