com.vaadin.server.ErrorMessage Java Examples

The following examples show how to use com.vaadin.server.ErrorMessage. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MPasswordField.java    From viritin with Apache License 2.0 6 votes vote down vote up
@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())});
}
 
Example #2
Source File: SpringSecurityErrorHandler.java    From Vaadin4Spring-MVP-Sample-SpringSecurity with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #3
Source File: WebResizableTextArea.java    From cuba with Apache License 2.0 5 votes vote down vote up
protected CubaTextArea createComponent() {
    return new CubaTextArea() {
        @Override
        public void setComponentError(ErrorMessage componentError) {
            if (componentError instanceof UserError) {
                super.setComponentError(componentError);
            } else {
                wrapper.setComponentError(componentError);
            }
        }
    };
}
 
Example #4
Source File: CubaTimeFieldWrapper.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void setComponentErrorProvider(Supplier<ErrorMessage> componentErrorProvider) {
    if (componentErrorProvider != null) {
        timeField.setComponentErrorProvider(() -> {
            ErrorMessage errorMessage = componentErrorProvider.get();
            amPmField.setComponentError(errorMessage);
            return errorMessage;
        });
    } else {
        timeField.setComponentErrorProvider(null);
    }
}
 
Example #5
Source File: CubaListSelect.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public ErrorMessage getErrorMessage() {
    ErrorMessage superError = super.getErrorMessage();
    if (!isReadOnly() && isRequired() && isEmpty()) {
        ErrorMessage error = AbstractErrorMessage.getErrorMessageForException(
                new com.vaadin.v7.data.Validator.EmptyValueException(getRequiredError()));
        if (error != null) {
            return new CompositeErrorMessage(superError, error);
        }
    }
    return superError;
}
 
Example #6
Source File: MTextField.java    From viritin with Apache License 2.0 5 votes vote down vote up
@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())});
}
 
Example #7
Source File: ClearableTextField.java    From viritin with Apache License 2.0 5 votes vote down vote up
@Override
public void setComponentError(ErrorMessage componentError) {
    super.setComponentError(componentError);
    if (componentError == null) {
        textfield.removeStyleName("error");
    } else {
        textfield.addStyleName("error");
    }
}
 
Example #8
Source File: CubaResizableTextAreaWrapper.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public ErrorMessage getErrorMessage() {
    ErrorMessage superError = super.getErrorMessage();
    if (!textArea.isReadOnly() && isRequiredIndicatorVisible() && textArea.isEmpty()) {
        ErrorMessage error = AbstractErrorMessage.getErrorMessageForException(
                new com.vaadin.v7.data.Validator.EmptyValueException(getRequiredError()));
        if (error != null) {
            return new CompositeErrorMessage(superError, error);
        }
    }

    return superError;
}
 
Example #9
Source File: ClearableTextField.java    From viritin with Apache License 2.0 5 votes vote down vote up
@Override
public ErrorMessage getErrorMessage() {
    final ErrorMessage errorMessage = super.getErrorMessage();
    if (errorMessage == null) {
        textfield.removeStyleName("error");
    } else {
        textfield.addStyleName("error");
    }
    return errorMessage;
}
 
Example #10
Source File: ClearableTextField.java    From viritin with Apache License 2.0 5 votes vote down vote up
@Override
public ErrorMessage getErrorMessage() {
    final ErrorMessage errorMessage = super.getErrorMessage();
    if (errorMessage == null) {
        textfield.removeStyleName("error");
    } else {
        textfield.addStyleName("error");
    }
    return errorMessage;
}
 
Example #11
Source File: ClearableTextField.java    From viritin with Apache License 2.0 5 votes vote down vote up
@Override
public void setComponentError(ErrorMessage componentError) {
    super.setComponentError(componentError);
    if (componentError == null) {
        textfield.removeStyleName("error");
    } else {
        textfield.addStyleName("error");
    }
}
 
Example #12
Source File: WebDateField.java    From cuba with Apache License 2.0 4 votes vote down vote up
protected ErrorMessage getErrorMessage() {
    return (isEditableWithParent() && isRequired() && isEmpty())
            ? new UserError(getRequiredMessage())
            : null;
}
 
Example #13
Source File: TypedSelect.java    From viritin with Apache License 2.0 4 votes vote down vote up
@Override
public ErrorMessage getErrorMessage() {
    final ErrorMessage errorMessage = super.getErrorMessage();
    getSelect().setStyleName("error", errorMessage != null);
    return errorMessage;
}
 
Example #14
Source File: CubaTimeFieldWrapper.java    From cuba with Apache License 2.0 4 votes vote down vote up
@Override
public Supplier<ErrorMessage> getComponentErrorProvider() {
    return timeField.getComponentErrorProvider();
}
 
Example #15
Source File: WebV8AbstractField.java    From cuba with Apache License 2.0 4 votes vote down vote up
protected ErrorMessage getErrorMessage() {
    return (isEditableWithParent() && isRequired() && isEmpty())
            ? new UserError(getRequiredMessage())
            : null;
}
 
Example #16
Source File: FluentAbstractComponent.java    From viritin with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the component's error message.
 *
 * @param componentError
 *            the new <code>ErrorMessage</code> of the component.
 * @return this (for method chaining)
 * @see AbstractComponent#setComponentError(com.vaadin.server.ErrorMessage)
 */
public default S withComponentError(ErrorMessage componentError) {
    ((AbstractComponent) this).setComponentError(componentError);
    return (S) this;
}
 
Example #17
Source File: CubaManagedTabSheet.java    From cuba with Apache License 2.0 votes vote down vote up
ErrorMessage getComponentError(); 
Example #18
Source File: CubaManagedTabSheet.java    From cuba with Apache License 2.0 votes vote down vote up
void setComponentError(ErrorMessage componentError);