Open icarrara opened 2 years ago
Continuing to search I found this interesting article:
"Double seven, Vaadin 7 with Liferay 7": https://liferay.dev/blogs/-/blogs/double-seven-vaadin-7-with-liferay-2
Unfortunately this article is also very old and refers to Vaadin 7.
It's a POC to demonstrate how to use Vaadin 7 (no OSGi) in Liferay 7 (OSGi) environment.
Here is the code in "Liferay 7 / Vaadin 7.5 OSGi integration PoC": https://github.com/sammso/liferay-vaadin7-osgi
I discovered also a Vaadin very old ticket here: " Add MANIFEST entries to support Liferay's OSGi container #7024 ": https://github.com/vaadin/framework/issues/7024
@icarrara first of all thank you so much for trying and testing Vaadin Portlet add-on with Liferay 7 and for a so huge observations and suggestions. These two features/integrations you mentioned can be a good candidates for future improvements of Vaadin Portlet:
It is critical for a Liferay developer to perform CRUD operations using Liferay APIs.
Obviously you can develop a Vaadin Portlet without using Liferay APIs, for example to retrieve data via REST and show them on a portal page using Vaadin Portlet 2.0.
But Vaadin Portlet cannot be a viable alternative to JSP or React to develop user interfaces for Liferay Portal if you don't know how to use Liferay APIs.
It would be great to see examples of how to bind data to Vaadin containers and use the Vaadin UI components to do CRUD using Liferay APIs.
Ideally, I would love to see a liferay-starter-flow-portlet Git project (starting from the base-starter-flow-portlet) adapted to a real Liferay portlet using Liferay ServiceBuilder for persistence.
Liferay ServiceBuilder is the framework that starting from a XML defining the data model, generates the whole stuff for persistence.
So a Liferay developer can use simple code to fetch a Liferay OOTB entity, for example a Liferay User:
com.liferay.portal.kernel.model.User liferayUser = com.liferay.portal.kernel.service.UserLocalServiceUtil.fetchUser(userId);
Or to fecth a custom entities developed using Liferay ServiceBuilder:
com.myProject.model.HousePrice housePrice = com.myProject.service.HousePriceLocalServiceUtil.getPriceByCode("house-14526");
At the same, a Liferay developer need to make use of an incredibly large library of Liferay utility classes, for example: `com.liferay.portal.kernel.util.StringUtil.appendParentheticalSuffix("Mr.", 0);
com.liferay.portal.kernel.model.PortletCategory.getRelevantPortletCategory(com.liferay.portal.kernel.security.permission.PermissionChecker permissionChecker, long companyId, com.liferay.portal.kernel.model.Layout layout, com.liferay.portal.kernel.model.PortletCategory portletCategory, com.liferay.portal.kernel.model.LayoutTypePortlet layoutTypePortlet);`
Finally, a Liferay developer must have access to ThemeDisplay which is one of the most important object that provides the developer with everything that describes the User's session related to the running Liferay instance:
ThemeDisplay provides general configuration methods for the portal, providing access to the portal's pages, sites, themes, locales, URLs, and more. This class is an information context object that holds data commonly referred to for various kinds of front-end information. Liferay makes the ThemeDisplay available as a request attribute and in various scripting and templating scopes. A typical way to obtain ThemeDisplay is from a request:
ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(com.liferay.portal.kernel.util.WebKeys.THEME_DISPLAY);
Maibe in Vaadin:
PortletRequest portletRequest = VaadinPortletService.getCurrentPortletRequest(); ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(com.liferay.portal.kernel.util.WebKeys.THEME_DISPLAY);
From themeDisplay, the methods below retrieve various Liferay Portal elements related to the logged-in user:
getCompanyId: Returns the company ID. getLanguageId: Returns the user’s language ID. getScopeGroupId: Returns the group ID of the current site. getUserId: Returns the user’s ID. getUserName: Returns the user’s name.
Another example:
if(Liferay.ThemeDisplay.isSignedIn()){ alert('Hello ' + themeDisplay.getUserName() + '. Welcome Back.') } else { alert('Hello Guest.') }
The only good example of integration between Vaadin UI and Liferay Portal that I have found is this blog post: "Developing a Portlet in Vaadin 7"
It is a great example of a portlet for Liferay written in Vaadin 7 for the Liferay shared Vaadin 7 environment. The code is a working Vaadin 7 portlet that lists all Liferay Users and allows review of some User details. It uses Maven and IntelliJ as IDE. The example also uses Vaadin IDE Eclipse plugin.
The project simply contains a page which shows basic Liferay User details and the User portrait/avatar. Works on a single user. Another component shows the list of Liferay Users. It leverages the Vaadin LazyPagedContainer to manage the pull of data from the Liferay API.
Unfortunately it uses Liferay version 6.2 but since Vaadin Portlet 2.0 does not use OSGI and a developed portlet is installed in Liferay as a WAR, the adaptations of this article to apply it to Vaadin Portlet 2.0 and Liferay 7.4 should be few, I hope.
Here is the blog article: https://liferay.dev/blogs/-/blogs/developing-a-portlet-in-vaadin-7
Here is the code: https://github.com/dnebinger/vaadin-sample-portlet
I general: To obtain the use of Liferay APIs in Liferay 7, for Gradle development a developer need to update Liferay Workspace to use the latest dependencies, by adding the following line to the "build.gradle" file:
dependencies { compileOnly group: "com.liferay.portal", name: "release.portal.api" }
All Liferay portal dependencies are now defined with a single declaration. When using an IDE such as Eclipse or IntelliJ all APIs are immediately available in autocomplete for immediate use.Or in Maven: `