Java tutorial
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package com.wintindustries.pfserver.interfaces.view.dashboard; import com.vaadin.navigator.View; import com.vaadin.navigator.ViewChangeListener; import com.vaadin.ui.Alignment; import com.vaadin.ui.CssLayout; import com.vaadin.ui.Label; import com.vaadin.ui.VerticalLayout; import java.io.PrintWriter; import java.io.StringWriter; /** * * @author Admin */ public class ErrorView extends CssLayout implements View { VerticalLayout errorInfo; public ErrorView() { setSizeUndefined(); // <-- This is the important part this.setStyleName("error-page"); setSizeFull(); errorInfo = new VerticalLayout(); this.addComponent(errorInfo); VerticalLayout errorTitle = new VerticalLayout(); Label pagetitle = new Label("500"); Label label = new Label("", Label.CONTENT_XHTML); label.setStyleName("error-page-line"); label.setWidth("400px"); pagetitle.setHeight("210px"); Label errorType = new Label("Internal Server Error"); pagetitle.setStyleName("error-page-title"); errorTitle.addComponent(pagetitle); errorTitle.addComponent(label); errorTitle.setComponentAlignment(pagetitle, Alignment.BOTTOM_LEFT); errorTitle.setWidth("90%"); errorInfo.setHeightUndefined(); errorInfo.addComponent(errorTitle); errorInfo.setComponentAlignment(errorTitle, Alignment.BOTTOM_LEFT); } public void displayErrorMessage(Exception ex, String title, String message) { VerticalLayout info = new VerticalLayout(); errorInfo.addComponent(info); errorInfo.setComponentAlignment(info, Alignment.TOP_LEFT); info.setStyleName("error-page-information"); if (title != null) { } if (message != null) { } if (ex != null) { Label label = new Label(); label.setContentMode(Label.CONTENT_XHTML); label.setCaption(ex.getLocalizedMessage()); info.addComponent(label); Label stacktraceLabel = new Label("Stacktrace"); info.addComponent(stacktraceLabel); Label stacktrace = new Label(); stacktrace.setWidth("50%"); stacktrace.setStyleName("error-page-stacktrace"); stacktrace.setCaptionAsHtml(true); StringWriter errors = new StringWriter(); ex.printStackTrace(new PrintWriter(errors)); stacktrace.setCaption(errors.toString()); info.addComponent(stacktrace); } } @Override public void enter(ViewChangeListener.ViewChangeEvent event) { } }