当前位置: 首页>>代码示例>>Java>>正文


Java VaadinResponse类代码示例

本文整理汇总了Java中com.vaadin.server.VaadinResponse的典型用法代码示例。如果您正苦于以下问题:Java VaadinResponse类的具体用法?Java VaadinResponse怎么用?Java VaadinResponse使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


VaadinResponse类属于com.vaadin.server包,在下文中一共展示了VaadinResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: handleConnectorRequest

import com.vaadin.server.VaadinResponse; //导入依赖的package包/类
@Override
public boolean handleConnectorRequest(VaadinRequest request,
		VaadinResponse response, String path) throws IOException {		
	final BusyIndicatorWindow busyIndicatorWindow = new BusyIndicatorWindow();
	final UI ui = UI.getCurrent();
	ui.access(() -> ui.addWindow(busyIndicatorWindow));
	try {
		//on charge le fichier
		getStreamSource().loadOndemandFile();
		if (getStreamSource().getStream()==null){
			return true;
		}
		getResource().setFilename(getStreamSource().getFileName());
		return super.handleConnectorRequest(request, response, path);
	}catch(Exception e){
		return true;
	}
	finally {
		busyIndicatorWindow.close();
	}		
}
 
开发者ID:EsupPortail,项目名称:esup-ecandidat,代码行数:22,代码来源:OnDemandFileDownloader.java

示例2: handleConnectorRequest

import com.vaadin.server.VaadinResponse; //导入依赖的package包/类
@Override
public boolean handleConnectorRequest(VaadinRequest request,
		VaadinResponse response, String path) throws IOException {		
	final BusyIndicatorWindow busyIndicatorWindow = new BusyIndicatorWindow();
	final UI ui = UI.getCurrent();
	ui.access(() -> ui.addWindow(busyIndicatorWindow));
	try {
		getStreamSource().loadOndemandFile();
		if (getStreamSource().getStream()==null){
			return true;
		}
		getDownloadStreamSource().setMIMEType("application/pdf");
		getDownloadStreamSource().getStream().setParameter(
                "Content-Disposition",
                "attachment; filename="+getStreamSource().getFileName());
		return super.handleConnectorRequest(request, response, path);
	}catch(Exception e){
		return true;
	}finally {
		busyIndicatorWindow.close();
	}		
}
 
开发者ID:EsupPortail,项目名称:esup-ecandidat,代码行数:23,代码来源:OnDemandPdfBrowserOpener.java

示例3: initRequestHandler

import com.vaadin.server.VaadinResponse; //导入依赖的package包/类
/**
 * initalize a unique RequestHandler
 */
private void initRequestHandler() {
	if (this.requestHandlerUri == null) {
		this.requestHandlerUri = UUID.randomUUID()
				.toString();
		VaadinSession.getCurrent()
				.addRequestHandler(new RequestHandler() {

					@Override
					public boolean handleRequest(final VaadinSession session, final VaadinRequest request, final VaadinResponse response)
							throws IOException {
						if (String.format("/%s", Jcrop.this.requestHandlerUri)
								.equals(request.getPathInfo())) {
							Jcrop.this.resource.getStream()
									.writeResponse(request, response);
							return true;
						} else {
							return false;
						}
					}
				});
	}
}
 
开发者ID:melistik,项目名称:vaadin-jcrop,代码行数:26,代码来源:Jcrop.java

示例4: onRequestEnd

import com.vaadin.server.VaadinResponse; //导入依赖的package包/类
@Override
public void onRequestEnd(VaadinRequest request, VaadinResponse response, VaadinSession session) {
    try {
        if (session != null) {
            SecurityContext securityContext = SecurityContextHolder.getContext();
            logger.trace("Storing security context {} in VaadinSession {}", securityContext, session);
            session.lock();
            try {
                session.setAttribute(SECURITY_CONTEXT_SESSION_ATTRIBUTE, securityContext);
            } finally {
                session.unlock();
            }
        } else {
            logger.trace("No VaadinSession available for storing the security context");
        }
    } finally {
        logger.trace("Clearing security context");
        SecurityContextHolder.clearContext();
    }
}
 
开发者ID:peholmst,项目名称:vaadin4spring,代码行数:21,代码来源:SecurityContextVaadinRequestListener.java

示例5: testInitNotMatchedPagelet

import com.vaadin.server.VaadinResponse; //导入依赖的package包/类
@Test
public void testInitNotMatchedPagelet() throws Exception {
    // variables
    String path = "/test";

    // mocks
    VaadinPageletTracker pageletTracker = createMock(VaadinPageletTracker.class);
    VaadinRequest request = createMock(VaadinRequest.class);

    // expect getting url path from request
    expect(request.getPathInfo()).andReturn(path);

    // expect matching path to pagelet
    expect(pageletTracker.matchPathToPagelet(path)).andReturn(null);

    // except returning HTTP 404
    VaadinResponse response = createMock(VaadinResponse.class);
    expect(CurrentInstance.get(VaadinResponse.class)).andReturn(response);
    response.sendError(HttpServletResponse.SC_NOT_FOUND, "Not found");

    // perform test
    replayAll();
    PageletAwareUI ui = new PageletAwareUI(pageletTracker);
    ui.init(request);
    verifyAll();
}
 
开发者ID:panifex,项目名称:panifex-platform,代码行数:27,代码来源:PageletAwareUITest.java

示例6: servletInitialized

import com.vaadin.server.VaadinResponse; //导入依赖的package包/类
@Override
protected void servletInitialized() throws ServletException {
	super.servletInitialized();

          HeaderTagHandler.init(getService());
	
	getService().addSessionInitListener(new SessionInitListener() {

		@Override
		public void sessionInit(SessionInitEvent event) throws ServiceException {
			event.getSession().addRequestHandler(new RequestHandler() {

				@Override
				public boolean handleRequest(VaadinSession session, VaadinRequest request,
						VaadinResponse response) throws IOException {

					String pathInfo = request.getPathInfo();
					InputStream in = null;

					if (pathInfo.endsWith("sw.js")) {
						response.setContentType("application/javascript");
						in = getClass().getResourceAsStream("/sw.js");
					}

					if (in != null) {
						OutputStream out = response.getOutputStream();
						IOUtils.copy(in, out);
						in.close();
						out.close();

						return true;
					} else {

						return false;
					}
				}
			});
		}
	});
}
 
开发者ID:amahdy,项目名称:java-pwa,代码行数:41,代码来源:MyUI.java

示例7: handleConnectorRequest

import com.vaadin.server.VaadinResponse; //导入依赖的package包/类
@Override
public boolean handleConnectorRequest(VaadinRequest request, VaadinResponse response, String path) throws IOException {
    StreamResource resource = new StreamResource(new StreamResource.StreamSource() {

        @Override
        public InputStream getStream() {
            byte[] doc = HybridbpmUI.getDocumentAPI().getDocumentBodyByVersionId(documentVersionId);
            return new ByteArrayInputStream(doc);
        }
    }, name);
    this.setResource("dl", resource);
    return super.handleConnectorRequest(request, response, path);
}
 
开发者ID:hybridbpm,项目名称:hybridbpm,代码行数:14,代码来源:DocumentHistoryLayout.java

示例8: handleConnectorRequest

import com.vaadin.server.VaadinResponse; //导入依赖的package包/类
@Override
public boolean handleConnectorRequest(VaadinRequest request, VaadinResponse response, String path) throws IOException {
    StreamResource resource = new StreamResource(() -> {
        Document doc = HybridbpmUI.getDocumentAPI().getDocumentById(documentId, true);
        return new ByteArrayInputStream(doc.getBody());
    }, name);
    this.setResource("dl", resource);
    return super.handleConnectorRequest(request, response, path);
}
 
开发者ID:hybridbpm,项目名称:hybridbpm,代码行数:10,代码来源:DocumentColumnGenerator.java

示例9: handleRequest

import com.vaadin.server.VaadinResponse; //导入依赖的package包/类
@Override
public boolean handleRequest(VaadinSession session,
		VaadinRequest request, VaadinResponse response)
		throws IOException {
	System.out.println("Requesting "+ request.getPathInfo());
	if (imageData != null && ("/" + uri).equals(request.getPathInfo())) {
		response.setContentType("image/png");
		ImageIO.write(imageData, "png", response.getOutputStream());
		return true;
	}
	return false;
}
 
开发者ID:samie,项目名称:trollator,代码行数:13,代码来源:DynamicImage.java

示例10: onRequestStart

import com.vaadin.server.VaadinResponse; //导入依赖的package包/类
@Override
public void onRequestStart(VaadinRequest request, VaadinResponse response) {
    final WrappedSession wrappedSession = request.getWrappedSession(false);
    VaadinSession session = null;
    if (wrappedSession != null) {
        session = VaadinSession.getForSession(request.getService(), wrappedSession);
    }

    SecurityContextHolder.clearContext();
    if (session != null) {
        logger.trace("Loading security context from VaadinSession {}", session);
        SecurityContext securityContext;
        session.lock();
        try {
            securityContext = (SecurityContext) session.getAttribute(SECURITY_CONTEXT_SESSION_ATTRIBUTE);
        } finally {
            session.unlock();
        }
        if (securityContext == null) {
            logger.trace("No security context found in VaadinSession {}", session);
        } else {
            logger.trace("Setting security context to {}", securityContext);
            SecurityContextHolder.setContext(securityContext);
        }
    } else {
        logger.trace("No VaadinSession available for retrieving the security context");
    }
}
 
开发者ID:peholmst,项目名称:vaadin4spring,代码行数:29,代码来源:SecurityContextVaadinRequestListener.java

示例11: requestStart

import com.vaadin.server.VaadinResponse; //导入依赖的package包/类
@Override
public void requestStart(VaadinRequest request, VaadinResponse response) {
    super.requestStart(request, response);
    logger.trace("Invoking VaadinRequestStartListeners");
    for (VaadinRequestStartListener listener : applicationContext.getBeansOfType(VaadinRequestStartListener.class).values()) {
        try {
            listener.onRequestStart(request, response);
        } catch (Exception ex) {
            logger.error("VaadinRequestStartListener threw an exception, ignoring", ex);
        }
    }
    logger.trace("Finished invoking VaadinRequestStartListeners");
}
 
开发者ID:peholmst,项目名称:vaadin4spring,代码行数:14,代码来源:Vaadin4SpringServletService.java

示例12: requestEnd

import com.vaadin.server.VaadinResponse; //导入依赖的package包/类
@Override
public void requestEnd(VaadinRequest request, VaadinResponse response, VaadinSession session) {
    logger.trace("Invoking VaadinRequestEndListeners");
    for (VaadinRequestEndListener listener : applicationContext.getBeansOfType(VaadinRequestEndListener.class).values()) {
        try {
            listener.onRequestEnd(request, response, session);
        } catch (Exception ex) {
            logger.error("VaadinRequestEndListener threw an exception, ignoring", ex);
        }
    }
    logger.trace("Finished invoking VaadinRequestEndListener");
    super.requestEnd(request, response, session);
}
 
开发者ID:peholmst,项目名称:vaadin4spring,代码行数:14,代码来源:Vaadin4SpringServletService.java

示例13: handleRequest

import com.vaadin.server.VaadinResponse; //导入依赖的package包/类
@Override
public boolean handleRequest(VaadinSession session,
                             VaadinRequest request,
                             VaadinResponse response)
        throws IOException {

	// does the request concern us?
	if (request.getPathInfo().startsWith("/popup"+imagePath)) { //$NON-NLS-1$
		ZipResult zipResult =
			(ZipResult) VaadinSession.getCurrent().getAttribute(
					SessionStorageKey.ZIPRESULT.name());
		// if this is about the example picture we use the example ZipResult
		if (request.getPathInfo().endsWith(examplePictureName)) {
			zipResult = exampleZipResult;
		}
		
		if (zipResult != null) {
			byte[] resource = zipResult.getExternalResource(
					request.getPathInfo().substring(PATH_PREFIX_LENGTH));
			if (resource != null) {
				response.getOutputStream().write(resource);
				return true;
			}
			else {
				throw new IOException(
					Messages.getString(
						"ExternalResourceRequestHandler.resourceNotFound",  //$NON-NLS-1$
						request.getPathInfo().substring(PATH_PREFIX_LENGTH)));
			}
		}
	}
	return false;
}
 
开发者ID:ADHO,项目名称:dhconvalidator,代码行数:34,代码来源:ExternalResourceRequestHandler.java

示例14: createRequestHandler

import com.vaadin.server.VaadinResponse; //导入依赖的package包/类
/**
  * Creates the parameter handler that will be invoked when the user returns
  * from the OAuth service.
  * 
  * @return the parameter handler
  */
 protected RequestHandler createRequestHandler() {
     return new RequestHandler() {
public boolean handleRequest(VaadinSession session,
		VaadinRequest request, VaadinResponse response)
		throws IOException {
             if (request.getParameterMap().containsKey(getVerifierName())) {
                 String v = request.getParameter(getVerifierName());
                 Verifier verifier = new Verifier(v);
                 accessToken = service
                         .getAccessToken(requestToken, verifier);

                 User user = getUser();

                 VaadinSession.getCurrent().removeRequestHandler(handler);
                 handler = null;
           
                 //String url = getAuthUrl();
                 //callbackPage.open(url, "Authentificate", 400, 300, BorderStyle.DEFAULT);
                 
                 authListener.userAuthenticated(user);

             } else if (getFailureParameters() != null) {
                 for (String key : getFailureParameters()) {
                     if (request.getParameterMap().containsKey(key)) {
                         authListener.failed(request.getParameter(key));
                         break;
                     }
                 }
             }
	return true;
         }
     };
 }
 
开发者ID:ahn,项目名称:mideaas,代码行数:40,代码来源:OAuthButton.java

示例15: onRequestStart

import com.vaadin.server.VaadinResponse; //导入依赖的package包/类
@Override
public void onRequestStart(final VaadinRequest request, final VaadinResponse response)
{
	updateMDC();
}
 
开发者ID:metasfresh,项目名称:metasfresh-procurement-webui,代码行数:6,代码来源:LoggingConfiguration.java


注:本文中的com.vaadin.server.VaadinResponse类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。