Java 类com.vaadin.server.ErrorMessage 实例源码

项目:metasfresh-procurement-webui    文件:AbstractErrorHandler.java   
@Override
public final void error(final ErrorEvent event)
{
    //
    // Extract the relevant exception
    Throwable t = event.getThrowable();
    if (t instanceof SocketException)
    {
        // Most likely client browser closed socket
        logger.info("SocketException in CommunicationManager. Most likely client (browser) closed socket.");
        return;
    }
    t = DefaultErrorHandler.findRelevantThrowable(t);

    //
    // Create error message
    final ErrorMessage errorMessage = createErrorMessage(t);

    //
    // Display it
    displayError(errorMessage, event);

    // also print the error on console
    logger.error("", t);
}
项目:cuba    文件:WebLookupField.java   
protected void createComponent() {
    this.component = new CubaComboBox() {
        @Override
        public void setPropertyDataSource(Property newDataSource) {
            if (newDataSource == null)
                super.setPropertyDataSource(null);
            else
                super.setPropertyDataSource(new LookupPropertyAdapter(newDataSource));
        }

        @Override
        public void setComponentError(ErrorMessage componentError) {
            boolean handled = false;
            if (componentErrorHandler != null)
                handled = componentErrorHandler.handleError(componentError);

            if (!handled)
                super.setComponentError(componentError);
        }
    };
}
项目:viritin    文件:MTextField.java   
@Override
public ErrorMessage getErrorMessage() {

    Validator.InvalidValueException validationError = getValidationError();

    final ErrorMessage superError = getComponentError();

    if (superError == null && validationError == null
            && getCurrentBufferedSourceException() == null) {
        return null;
    }
    // Throw combination of the error types
    return new CompositeErrorMessage(
            new ErrorMessage[]{
                superError,
                AbstractErrorMessage
                .getErrorMessageForException(validationError),
                AbstractErrorMessage
                .getErrorMessageForException(
                        getCurrentBufferedSourceException())});
}
项目:viritin    文件:MPasswordField.java   
@Override
public ErrorMessage getErrorMessage() {

    Validator.InvalidValueException validationError = getValidationError();

    final ErrorMessage superError = getComponentError();

    if (superError == null && validationError == null
            && getCurrentBufferedSourceException() == null) {
        return null;
    }
    // Throw combination of the error types
    return new CompositeErrorMessage(
            new ErrorMessage[]{
                superError,
                AbstractErrorMessage
                .getErrorMessageForException(validationError),
                AbstractErrorMessage
                .getErrorMessageForException(
                        getCurrentBufferedSourceException())});
}
项目:holon-vaadin7    文件:AbstractCustomField.java   
@Override
public void setComponentError(ErrorMessage componentError) {
    super.setComponentError(componentError);
    if (componentError != null) {
        addStyleName(DEFAULT_INVALID_FIELD_STYLE_CLASS);
    } else {
        removeStyleName(DEFAULT_INVALID_FIELD_STYLE_CLASS);
    }
}
项目:holon-vaadin    文件:AbstractCustomField.java   
@Override
public void setComponentError(ErrorMessage componentError) {
    super.setComponentError(componentError);
    if (componentError != null) {
        addStyleName(DEFAULT_INVALID_FIELD_STYLE_CLASS);
    } else {
        removeStyleName(DEFAULT_INVALID_FIELD_STYLE_CLASS);
    }
}
项目:bootstrap-formgroup    文件:FormGroupTextFieldOverwriteModeUI.java   
@Override
public Component getTestComponent() {

    TextFieldGroup field = new TextFieldGroup();

    field.setCaption("Caption");
    field.setDescription("Description");
    field.setMode(BootstrapMode.SUCCESS);

    Button action1 = new Button("Add ErrorMessage");
    action1.setId("action1");
    action1.addClickListener(event -> {
        field.getField().setComponentError(new ErrorMessage() {
            @Override
            public ErrorLevel getErrorLevel() {
                return ErrorLevel.ERROR;
            }

            @Override
            public String getFormattedHtmlMessage() {
                return "<strong>ERROR HERE</strong>";
            }
        });
    });

    Button action2 = new Button("Remove ErrorMessage");
    action2.setId("action2");
    action2.addClickListener(event -> {
        field.setOverwriteModeIfComponentError(false);
        field.getField().setComponentError(null);
    });

    MyCustomLayout layout = new MyCustomLayout(FormGroupHtml.BASIC, action1, action2);
    layout.addComponent(field, "field");

    return layout;
}
项目:bootstrap-formgroup    文件:FormGroupTextFieldErrorMessageUI.java   
@Override
public Component getTestComponent() {

    TextFieldGroup field = new TextFieldGroup();

    field.setCaption("Caption");
    field.setDescription("Description");

    Button action1 = new Button("Add ErrorMessage");
    action1.setId("action1");
    action1.addClickListener(event -> {
        field.getField().setComponentError(new ErrorMessage() {
            @Override
            public ErrorLevel getErrorLevel() {
                return ErrorLevel.ERROR;
            }

            @Override
            public String getFormattedHtmlMessage() {
                return "<strong>ERROR HERE</strong>";
            }
        });
    });

    Button action2 = new Button("Remove ErrorMessage");
    action2.setId("action2");
    action2.addClickListener(event -> {
        field.getField().setComponentError(null);
    });

    MyCustomLayout layout = new MyCustomLayout(FormGroupHtml.BASIC, action1, action2);
    layout.addComponent(field, "field");

    return layout;
}
项目:metasfresh-procurement-webui    文件:ForwardingErrorHandler.java   
@Override
protected void displayError(final ErrorMessage errorMessage, final ErrorEvent event)
{
    if (component != null)
    {
        component.setComponentError(errorMessage);
    }
}
项目:metasfresh-procurement-webui    文件:AbstractErrorHandler.java   
private ErrorMessage createErrorMessage(final Throwable t)
{
    final ErrorMessage errorMessage = AbstractErrorMessage.getErrorMessageForException(t);

    // In case we deal with an System Error, don't show it to user because it's confusing.
    // Instead show a generic friendly error message.
    if (errorMessage instanceof SystemError)
    {
        return new UserError(i18n.get("error.default"));
    }

    return errorMessage;
}
项目:cuba    文件:CubaPasswordField.java   
@Override
public ErrorMessage getErrorMessage() {
    ErrorMessage superError = super.getErrorMessage();
    if (!isReadOnly() && isRequired() && isEmpty()) {

        ErrorMessage error = AbstractErrorMessage.getErrorMessageForException(
                new com.vaadin.data.Validator.EmptyValueException(getRequiredError()));
        if (error != null) {
            return new CompositeErrorMessage(superError, error);
        }
    }

    return superError;
}
项目:cuba    文件:CubaListSelect.java   
@Override
public ErrorMessage getErrorMessage() {
    ErrorMessage superError = super.getErrorMessage();
    if (!isReadOnly() && isRequired() && isEmpty()) {
        ErrorMessage error = AbstractErrorMessage.getErrorMessageForException(
                new com.vaadin.data.Validator.EmptyValueException(getRequiredError()));
        if (error != null) {
            return new CompositeErrorMessage(superError, error);
        }
    }
    return superError;
}
项目:cuba    文件:CubaSourceCodeEditor.java   
@Override
public ErrorMessage getErrorMessage() {
    ErrorMessage superError = super.getErrorMessage();
    if (!isReadOnly() && isRequired() && isEmpty()) {
        ErrorMessage error = AbstractErrorMessage.getErrorMessageForException(
                new com.vaadin.data.Validator.EmptyValueException(getRequiredError()));
        if (error != null) {
            return new CompositeErrorMessage(superError, error);
        }
    }

    return superError;
}
项目:cuba    文件:CubaDateFieldWrapper.java   
@Override
public ErrorMessage getErrorMessage() {
    ErrorMessage superError = super.getErrorMessage();
    if (!isReadOnly() && isRequired() && isEmpty()) {
        ErrorMessage error = AbstractErrorMessage.getErrorMessageForException(
                new com.vaadin.data.Validator.EmptyValueException(getRequiredError()));
        if (error != null) {
            return new CompositeErrorMessage(superError, error);
        }
    }
    return superError;
}
项目:cuba    文件:CubaResizableTextAreaWrapper.java   
@Override
public ErrorMessage getErrorMessage() {
    ErrorMessage superError = super.getErrorMessage();
    if (!textArea.isReadOnly() && isRequired() && textArea.isEmpty()) {
        ErrorMessage error = AbstractErrorMessage.getErrorMessageForException(
                new com.vaadin.data.Validator.EmptyValueException(getRequiredError()));
        if (error != null) {
            return new CompositeErrorMessage(superError, error);
        }
    }

    return superError;
}
项目:cuba    文件:CubaTextArea.java   
@Override
public ErrorMessage getErrorMessage() {
    ErrorMessage superError = super.getErrorMessage();
    if (!isReadOnly() && isRequired() && isEmpty()) {
        ErrorMessage error = AbstractErrorMessage.getErrorMessageForException(
                new com.vaadin.data.Validator.EmptyValueException(getRequiredError()));
        if (error != null) {
            return new CompositeErrorMessage(superError, error);
        }
    }
    return superError;
}
项目:cuba    文件:WebResizableTextArea.java   
@Override
protected CubaTextArea createTextFieldImpl() {
    return new CubaTextArea() {
        @Override
        public void setComponentError(ErrorMessage componentError) {
            if (componentError instanceof UserError) {
                super.setComponentError(componentError);
            } else {
                wrapper.setComponentError(componentError);
            }
        }
    };
}
项目:cuba    文件:WebSearchField.java   
@Override
protected void createComponent() {
    this.component = new CubaSearchSelect() {
        @Override
        public void setPropertyDataSource(Property newDataSource) {
            if (newDataSource == null) {
                super.setPropertyDataSource(null);
            } else {
                super.setPropertyDataSource(new LookupPropertyAdapter(newDataSource));
            }
        }

        @Override
        public void setComponentError(ErrorMessage componentError) {
            boolean handled = false;
            if (componentErrorHandler != null) {
                handled = componentErrorHandler.handleError(componentError);
            }

            if (!handled) {
                super.setComponentError(componentError);
            }
        }
    };

    getSearchComponent().setFilterHandler(this::executeSearch);
}
项目:cuba    文件:CubaFileUploadWrapper.java   
@Override
public ErrorMessage getErrorMessage() {
    ErrorMessage superError = super.getErrorMessage();
    if (!isReadOnly() && isRequired() && isEmpty()) {
        ErrorMessage error = AbstractErrorMessage.getErrorMessageForException(
                new com.vaadin.data.Validator.EmptyValueException(getRequiredError()));
        if (error != null) {
            return new CompositeErrorMessage(superError, error);
        }
    }
    return superError;
}
项目:cuba    文件:WebDataGrid.java   
@Override
public ErrorMessage getErrorMessage() {
    try {
        validate();
    } catch (Validator.InvalidValueException ignore) {
    }
    return getContent().getErrorMessage();
}
项目:minimal-j    文件:VaadinIndication.java   
public static void setValidationMessages(List<String> validationMessages, AbstractComponent component) {
    if (validationMessages.isEmpty()) {
        component.setComponentError(null);
    } else if (validationMessages.size() == 1) {
        component.setComponentError(new UserError(validationMessages.get(0)));
    } else {
        ErrorMessage[] errorMessages = new ErrorMessage[validationMessages.size()];
        for (int i = 0; i<validationMessages.size(); i++) {
            errorMessages[i] = new UserError(validationMessages.get(i));
        }
        CompositeErrorMessage compositeErrorMessage = new CompositeErrorMessage(errorMessages);
        component.setComponentError(compositeErrorMessage);
    }
}
项目:viritin    文件:ClearableTextField.java   
@Override
public ErrorMessage getErrorMessage() {
    final ErrorMessage errorMessage = super.getErrorMessage();
    if (errorMessage == null) {
        textfield.removeStyleName("error");
    } else {
        textfield.addStyleName("error");
    }
    return errorMessage;
}
项目:viritin    文件:ClearableTextField.java   
@Override
public void setComponentError(ErrorMessage componentError) {
    super.setComponentError(componentError);
    if (componentError == null) {
        textfield.removeStyleName("error");
    } else {
        textfield.addStyleName("error");
    }
}
项目:viritin    文件:ClearableTextField.java   
@Override
public ErrorMessage getErrorMessage() {
    final ErrorMessage errorMessage = super.getErrorMessage();
    if (errorMessage == null) {
        textfield.removeStyleName("error");
    } else {
        textfield.addStyleName("error");
    }
    return errorMessage;
}
项目:viritin    文件:ClearableTextField.java   
@Override
public void setComponentError(ErrorMessage componentError) {
    super.setComponentError(componentError);
    if (componentError == null) {
        textfield.removeStyleName("error");
    } else {
        textfield.addStyleName("error");
    }
}
项目:Vaadin4Spring-MVP-Sample-SpringSecurity    文件:SpringSecurityErrorHandler.java   
public static void doDefault(ErrorEvent event) {
    Throwable t = event.getThrowable();
    if (t instanceof SocketException) {
        // Most likely client browser closed socket
        getLogger().info(
                "SocketException in CommunicationManager."
                        + " Most likely client (browser) closed socket.");
        return;
    }

    t = findRelevantThrowable(t);

    /*
     * Handle SpringSecurity 
     */
    if (t instanceof AccessDeniedException) {

        EventBus eventBus = SpringApplicationContext.getEventBus();
        eventBus.publish(EventScope.UI, eventBus, new AccessDeniedEvent(t));

        getLogger().log(Level.FINE, "Access is denied", t);
        return;
    }

    // Finds the original source of the error/exception
    AbstractComponent component = findAbstractComponent(event);
    if (component != null) {
        // Shows the error in AbstractComponent
        ErrorMessage errorMessage = AbstractErrorMessage
                .getErrorMessageForException(t);
        component.setComponentError(errorMessage);
    }

    // also print the error on console
    getLogger().log(Level.SEVERE, "", t);
}
项目:hypothesis    文件:SelectPanel.java   
@Override
public ErrorMessage getErrorMessage() {

    /*
     * Check validation errors only if automatic validation is enabled.
     * Empty, required fields will generate a validation error containing
     * the requiredError string. For these fields the exclamation mark will
     * be hidden but the error must still be sent to the client.
     */
    InvalidValueException validationError = null;
    if (isValidationVisible()) {
        try {
            validate();
        } catch (InvalidValueException e) {
            if (!e.isInvisible()) {
                validationError = e;
            }
        }
    }

    // Check if there are any systems errors
    final ErrorMessage superError = super.getErrorMessage();

    // Return if there are no errors at all
    if (superError == null && validationError == null) {
        return null;
    }

    // Throw combination of the error types
    return new CompositeErrorMessage(
            new ErrorMessage[] { superError, AbstractErrorMessage.getErrorMessageForException(validationError) });
}
项目:VaadinUtils    文件:ReportParameterTable.java   
public void validateMe()
{

    grid.setComponentError(null);
    setComponentErrorForValidateListener(null);
    grid.setComponentError(null);
    setComponentErrorForValidateListener(null);
    Collection<Long> ids = getSelectedIds();
    if (ids.size() == 0)
    {
        ErrorMessage error = new ErrorMessage()
        {

            private static final long serialVersionUID = -6437991860908562482L;

            @Override
            public ErrorLevel getErrorLevel()
            {
                return ErrorLevel.ERROR;
            }

            @Override
            public String getFormattedHtmlMessage()
            {
                return "You must select at least one " + caption;
            }
        };
        grid.setComponentError(error);
        setComponentErrorForValidateListener(error);

    }

}
项目:VaadinUtils    文件:ReportParameterTable.java   
private void setComponentErrorForValidateListener(ErrorMessage error)
{
    if (validateListener != null)
    {
        validateListener.setComponentError(error);
    }
}
项目:VaadinUtils    文件:TableCheckBoxSelect.java   
private boolean validateField()
{
    boolean valid = false;
    try
    {
        setComponentError(null);
        validate();
        valid = true;
    }
    catch (final InvalidValueException e)
    {
        setComponentError(new ErrorMessage()
        {

            private static final long serialVersionUID = -2976235476811651668L;

            @Override
            public String getFormattedHtmlMessage()
            {
                return e.getHtmlMessage();
            }

            @Override
            public ErrorLevel getErrorLevel()
            {
                return ErrorLevel.ERROR;
            }
        });
    }
    return valid;

}
项目:VaadinUtils    文件:TableCheckBoxSingleSelect.java   
private boolean validateField()
{
    boolean valid = false;
    try
    {
        setComponentError(null);
        validate();
        valid = true;
    }
    catch (final InvalidValueException e)
    {
        setComponentError(new ErrorMessage()
        {

            private static final long serialVersionUID = -2976235476811651668L;

            @Override
            public String getFormattedHtmlMessage()
            {
                return e.getHtmlMessage();
            }

            @Override
            public ErrorLevel getErrorLevel()
            {
                return ErrorLevel.ERROR;
            }
        });
    }
    return valid;

}
项目:material-theme-fw8    文件:MDTextField.java   
@Override
public void setComponentError(ErrorMessage componentError) {
    super.setComponentError(componentError);
    setError(componentError == null ? null : ((AbstractErrorMessage) componentError).getMessage());
}
项目:material-theme-fw8    文件:MDTextField.java   
@Override
public void setComponentError(ErrorMessage componentError) {
    field.setComponentError(componentError);
}
项目:material-theme-fw8    文件:MDDateTimeField.java   
@Override
public void setComponentError(ErrorMessage componentError) {
    super.setComponentError(componentError);
    setError(componentError == null ? null : ((AbstractErrorMessage) componentError).getMessage());
}
项目:material-theme-fw8    文件:MDDateTimeField.java   
@Override
public void setComponentError(ErrorMessage componentError) {
    field.setComponentError(componentError);
}
项目:material-theme-fw8    文件:MDTextFieldBox.java   
@Override
public void setComponentError(ErrorMessage componentError) {
    super.setComponentError(componentError);
    setError(componentError == null ? null : ((AbstractErrorMessage) componentError).getMessage());
}
项目:material-theme-fw8    文件:MDTextFieldBox.java   
@Override
public void setComponentError(ErrorMessage componentError) {
    field.setComponentError(componentError);
}
项目:material-theme-fw8    文件:MDDateField.java   
@Override
public void setComponentError(ErrorMessage componentError) {
    super.setComponentError(componentError);
    setError(componentError == null ? null : ((AbstractErrorMessage) componentError).getMessage());
}
项目:material-theme-fw8    文件:MDDateField.java   
@Override
public void setComponentError(ErrorMessage componentError) {
    field.setComponentError(componentError);
}
项目:material-theme-fw8    文件:MDTextAreaBox.java   
@Override
public void setComponentError(ErrorMessage componentError) {
    super.setComponentError(componentError);
    setError(componentError == null ? null : ((AbstractErrorMessage) componentError).getMessage());
}