mirror of
https://gitee.com/jmix/cuba.git
synced 2024-11-30 18:27:56 +08:00
JQuery integration #PL-2403
This commit is contained in:
parent
b168e4c2f1
commit
3de4085975
@ -60,7 +60,7 @@ def desktopModule = project(':cuba-desktop')
|
||||
def portalModule = project(':cuba-portal')
|
||||
def webAuthModule = project(':cuba-web-auth')
|
||||
|
||||
def vaadinVersion = '7.1.3.h.M6'
|
||||
def vaadinVersion = '7.1.3.h.M7'
|
||||
|
||||
def servletApi = [group: 'org.apache.tomcat', name: 'servlet-api', version: '6.0.20']
|
||||
def groovyArtifact = [group: 'org.codehaus.groovy', name: 'groovy-all', version: '2.1.6']
|
||||
|
@ -9,6 +9,7 @@ package com.haulmont.cuba.web;
|
||||
import com.haulmont.cuba.core.global.AppBeans;
|
||||
import com.haulmont.cuba.core.global.Configuration;
|
||||
import com.haulmont.cuba.web.sys.LinkHandler;
|
||||
import com.haulmont.cuba.web.toolkit.ui.CubaJQueryIntegration;
|
||||
import com.vaadin.annotations.PreserveOnRefresh;
|
||||
import com.vaadin.server.*;
|
||||
import com.vaadin.ui.Component;
|
||||
@ -40,6 +41,8 @@ public class AppUI extends UI implements ErrorHandler {
|
||||
App app = createApplication();
|
||||
VaadinSession.getCurrent().setAttribute(App.class, app);
|
||||
|
||||
new CubaJQueryIntegration().extend(this);
|
||||
|
||||
applicationInitRequired = true;
|
||||
}
|
||||
}
|
||||
@ -83,7 +86,6 @@ public class AppUI extends UI implements ErrorHandler {
|
||||
// place login/main window
|
||||
App.getInstance().initView();
|
||||
|
||||
|
||||
processExternalLink(request);
|
||||
}
|
||||
|
||||
|
@ -14,8 +14,12 @@ import com.haulmont.cuba.core.sys.AppContext;
|
||||
import com.haulmont.cuba.web.App;
|
||||
import com.haulmont.cuba.web.WebConfig;
|
||||
import com.vaadin.server.*;
|
||||
import com.vaadin.server.communication.PublishedFileHandler;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
@ -24,9 +28,9 @@ import java.util.Locale;
|
||||
*/
|
||||
public class CubaVaadinServletService extends VaadinServletService {
|
||||
|
||||
private WebConfig webConfig;
|
||||
protected WebConfig webConfig;
|
||||
|
||||
private final String webResourceTimestamp;
|
||||
protected final String webResourceTimestamp;
|
||||
|
||||
public CubaVaadinServletService(VaadinServlet servlet, DeploymentConfiguration deploymentConfiguration)
|
||||
throws ServiceException {
|
||||
@ -96,4 +100,30 @@ public class CubaVaadinServletService extends VaadinServletService {
|
||||
public String getApplicationVersion() {
|
||||
return webResourceTimestamp;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected List<RequestHandler> createRequestHandlers() throws ServiceException {
|
||||
List<RequestHandler> requestHandlers = super.createRequestHandlers();
|
||||
// replace PublishedFileHandler for support resources from VAADIN directory
|
||||
|
||||
List<RequestHandler> cubaRequestHandlers = new ArrayList<>();
|
||||
for (RequestHandler handler : requestHandlers) {
|
||||
if (handler instanceof PublishedFileHandler) {
|
||||
// replace PublishedFileHandler with CubaPublishedFileHandler
|
||||
cubaRequestHandlers.add(new CubaPublishedFileHandler());
|
||||
} else {
|
||||
cubaRequestHandlers.add(handler);
|
||||
}
|
||||
}
|
||||
|
||||
return cubaRequestHandlers;
|
||||
}
|
||||
|
||||
// Add ability to load JS and CSS resources from VAADIN directory
|
||||
protected static class CubaPublishedFileHandler extends PublishedFileHandler {
|
||||
@Override
|
||||
protected InputStream getApplicationResourceAsStream(Class<?> contextClass, String fileName) {
|
||||
return VaadinServlet.getCurrent().getServletContext().getResourceAsStream("VAADIN/" + fileName);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (c) 2013 Haulmont Technology Ltd. All Rights Reserved.
|
||||
* Haulmont Technology proprietary and confidential.
|
||||
* Use is subject to license terms.
|
||||
*/
|
||||
|
||||
package com.haulmont.cuba.web.toolkit.ui;
|
||||
|
||||
import com.vaadin.annotations.JavaScript;
|
||||
import com.vaadin.server.AbstractClientConnector;
|
||||
import com.vaadin.server.AbstractJavaScriptExtension;
|
||||
import com.vaadin.server.ClientConnector;
|
||||
import com.vaadin.ui.UI;
|
||||
|
||||
/**
|
||||
* @author artamonov
|
||||
* @version $Id$
|
||||
*/
|
||||
@JavaScript("resources/jquery/jquery-1.10.2.min.js")
|
||||
public class CubaJQueryIntegration extends AbstractJavaScriptExtension {
|
||||
|
||||
@Override
|
||||
public void extend(AbstractClientConnector target) {
|
||||
super.extend(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class<? extends ClientConnector> getSupportedParentType() {
|
||||
return UI.class;
|
||||
}
|
||||
}
|
6
modules/web/web/VAADIN/resources/jquery/jquery-1.10.2.min.js
vendored
Normal file
6
modules/web/web/VAADIN/resources/jquery/jquery-1.10.2.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user