Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Liferay edit mode: content disappears when moving portlet in another position #211

Open
mcollovati opened this issue Mar 11, 2022 · 1 comment
Labels
bug Something isn't working Liferay

Comments

@mcollovati
Copy link
Contributor

While editing a Liferay Content Page, when a Vaadin portlet is moved from a position to another its content is no more visible.
The issue seems to happen mainly when moving widgets inside layout containers.

To reproduce this bug:

  • Build adressbook-portlet example and deploy it to the Liferay by copying in to {liferay_home}/deploy folder.
  • Open localhost:8080 and login into Liferay
  • Click on the "Edit" icon to start edit the page
  • Open "Fragments and Widgets" panel on the right side of the page, go to "Widget" tab
  • Find "Vaadin Sample" category on the botton and then "ContactList" element
  • Drag and drop the widget to the page.
  • Click on the "Publish" button to exit from editing mode to browse mode and click "Edit" icon again (this is needed until Vaadin Portlet content is blank in Liferay 7 page editing mode #202 is fixed).
  • Drag and drop the widget in another position, for example over the "Welcome to Liferay" text
  • Check that the portlet/widget is blank

Expected behavior: Portlet content is rendered
Actual behavior: Portlet content is not rendered

Versions:
Vaadin Portlet version - 1.0.0.beta4
Flow version - 2.7.8
Liferay version - 7.4
Java version - 11

@mcollovati mcollovati added the bug Something isn't working label Mar 11, 2022
@mcollovati
Copy link
Contributor Author

At a first glance, it seems like that the problem is that when moving the portlet, a new web-component with a different id is created on the client side and a new server-side Java view component is instantiated. However, in VaadinPortlet.initComponent an already existing PortletViewContext is found, but with a reference to the previous java component instance.

Since the PortletViewContext is found, onPortletViewContextInit is not invoked on the new component, so, if the component tree is built on that method, the result on the client side will be an empty element.

A quick and dirty fix may be to check if context view is the same as the component that is being initialized, and if not create and set a new PortletViewContext, but perhaps it may be worth to do some further investigation.

// if (context == null) { // Actual code
if (context == null || context.getView() != component) { // Fix
    needViewInit = true;
    context = new PortletViewContext(component, portlet.isPortlet3,
            request.getPortletMode(), request.getWindowState());
    portlet.setViewContext(session, namespace, windowName, context);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Liferay
Projects
Status: 🔖 Normal Priority (P2)
Development

No branches or pull requests

1 participant