本文整理汇总了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();
}
}
示例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();
}
}
示例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;
}
}
});
}
}
示例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();
}
}
示例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();
}
示例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;
}
}
});
}
});
}
示例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);
}
示例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);
}
示例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;
}
示例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");
}
}
示例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");
}
示例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);
}
示例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;
}
示例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;
}
};
}
示例15: onRequestStart
import com.vaadin.server.VaadinResponse; //导入依赖的package包/类
@Override
public void onRequestStart(final VaadinRequest request, final VaadinResponse response)
{
updateMDC();
}