Closed mshabarov closed 2 years ago
A similar issue is observed for Anchor
and HtmlComponent
components, missing attributes are href
and data
respectively.
The problem may be in the client side SimpleElementBindingStrategy.updateAttributeValue
method; when handling stream resources in web-component mode the original uri is prepended with configuration.getServiceUrl()
.
So, for example, the generated target URL http://localhost:8080/web/guest/mytest?p_p_id=ContactForm_WAR_addressbookform_INSTANCE_sjpi&p_p_lifecycle=2&p_p_state=normal&p_p_mode=view&p_p_resource_id=%2FVAADIN%2Fdynamic%2Fresource%2F0%2Fe423052f-b804-4af5-8873-efaf9c60193e%2Fupload&p_p_cacheability=cacheLevelPage
becomes http://localhost:8080/web/guest/mytest?p_p_id=ContactForm_WAR_addressbookform_INSTANCE_sjpi&p_p_lifecycle=2&p_p_state=normal&p_p_mode=view&p_p_resource_id=%2Fuidl&p_p_cacheability=cacheLevelPage/http://localhost:8080/web/guest/mytest?p_p_id=ContactForm_WAR_addressbookform_INSTANCE_sjpi&p_p_lifecycle=2&p_p_state=normal&p_p_mode=view&p_p_resource_id=%2FVAADIN%2Fdynamic%2Fresource%2F0%2Fe423052f-b804-4af5-8873-efaf9c60193e%2Fupload&p_p_cacheability=cacheLevelPage
.
A quickfix for Liferay problem may be using URL as is on client side, if it is absolute.
String uri = object.getString(NodeProperties.URI_ATTRIBUTE);
if (configuration.isWebComponentMode()) {
String baseUri = configuration.getServiceUrl();
baseUri = baseUri.endsWith("/") ? baseUri : baseUri + "/";
WidgetUtil.updateAttribute(element, attribute,
baseUri + uri);
} else {
WidgetUtil.updateAttribute(element, attribute, uri);
}
Seems like that handling absolute URL case in SimpleElementBindingStrategy.updateAttributeValue()
fixes the problem.
Should we move this issue to flow repository? Or better create a new one?
@mcollovati thanks for comprehensive analysis. Indeed, as this problem isn't specific for vaadin-portlet
and impacts the components whose use StreamResource in web-component mode (embedded), it would be better to fix it on Flow side. I'm closing this ticket in favor of https://github.com/vaadin/flow/issues/13288.
Description of the bug As a developer, I want to use
Upload
component in my Liferay portlet application to upload the file to the server. The code used is as follows:This silently doesn't work with Liferay, however work in a regular servlet application. No exceptions or any other errors in the log, upload component shows that the file is uploaded, however, server side listener is not invoked. The problem is in
target
attribute of the upload component. Something rewrites it on the client side. Workaround is to place the following code just after component initialization:feature/liferay