ApplicationConstants.SERVICE_URL_PATH_AS_PARAMETER) == Boolean.TRUE;
}
+ /**
+ * Return the name of the parameter used to to send data to the service url.
+ * This method should only be called if {@link #useServiceUrlPathParam()} is
+ * true.
+ *
+ * @since 7.1.6
+ * @return The parameter name, by default <code>v-resourcePath</code>
+ */
+ public String getServiceUrlParameterName() {
+ String prefix = getJsoConfiguration(id).getConfigString(
+ ApplicationConstants.SERVICE_URL_PARAMETER_NAMESPACE);
+ if (prefix == null) {
+ prefix = "";
+ }
+ return prefix + ApplicationConstants.V_RESOURCE_PATH;
+ }
+
public String getRootPanelId() {
return id;
}
if (!path.startsWith("/")) {
path = '/' + path;
}
- String pathParam = ApplicationConstants.V_RESOURCE_PATH + "="
+ String pathParam = conf.getServiceUrlParameterName() + "="
+ URL.encodeQueryString(path);
serviceUrl = addGetParameters(serviceUrl, pathParam);
uidlUri = serviceUrl;
* @return A wrapped version of the PorletRequest
*/
protected VaadinPortletRequest createVaadinRequest(PortletRequest request) {
- String portalInfo = request.getPortalContext().getPortalInfo()
- .toLowerCase();
- if (portalInfo.contains("liferay")) {
+ if (isLiferay(request)) {
return new VaadinLiferayRequest(request, getService());
- } else if (portalInfo.contains("gatein")) {
+ } else if (isGateIn(request)) {
return new VaadinGateinRequest(request, getService());
} else {
return new VaadinPortletRequest(request, getService());
}
+ }
+ /**
+ * Returns true if the portlet request is from Liferay.
+ *
+ * @param request
+ * @return True if Liferay, false otherwise
+ */
+ private static boolean isLiferay(PortletRequest request) {
+ String portalInfo = request.getPortalContext().getPortalInfo()
+ .toLowerCase();
+ return portalInfo.contains("liferay");
+ }
+
+ /**
+ * Returns true if the portlet request if from GateIn
+ *
+ * @param request
+ * @return True if GateIn, false otherwise
+ */
+ private static boolean isGateIn(PortletRequest request) {
+ String portalInfo = request.getPortalContext().getPortalInfo()
+ .toLowerCase();
+ return portalInfo.contains("gatein");
}
private VaadinPortletResponse createVaadinResponse(PortletResponse response) {
import com.vaadin.server.BootstrapHandler;
import com.vaadin.server.PaintException;
import com.vaadin.server.VaadinPortlet;
+import com.vaadin.server.VaadinPortlet.VaadinLiferayRequest;
import com.vaadin.server.VaadinPortletRequest;
import com.vaadin.server.VaadinPortletResponse;
import com.vaadin.server.VaadinRequest;
JSONObject parameters = super.getApplicationParameters(context);
VaadinPortletResponse response = (VaadinPortletResponse) context
.getResponse();
+ VaadinPortletRequest request = (VaadinPortletRequest) context
+ .getRequest();
MimeResponse portletResponse = (MimeResponse) response
.getPortletResponse();
ResourceURL resourceURL = portletResponse.createResourceURL();
parameters
.put(ApplicationConstants.SERVICE_URL_PATH_AS_PARAMETER, true);
+ // If we are running in Liferay then we need to prefix all parameters
+ // with the portlet namespace
+ if (request instanceof VaadinLiferayRequest) {
+ parameters.put(
+ ApplicationConstants.SERVICE_URL_PARAMETER_NAMESPACE,
+ response.getPortletResponse().getNamespace());
+ }
+
return parameters;
}
}
\ No newline at end of file
public static final String SERVICE_URL_PATH_AS_PARAMETER = "usePathParameter";
+ // Denotes the namespace which parameters should be prefixed with when
+ // passed as GET parameters. Currently only used by Liferay.
+ public static final String SERVICE_URL_PARAMETER_NAMESPACE = "pathParameterNS";
+
// Javadocs in ApplicationConfiguration should be updated if this is changed
public static final String V_RESOURCE_PATH = "v-resourcePath";