Example usage for org.apache.wicket Component error

List of usage examples for org.apache.wicket Component error

Introduction

In this page you can find the example usage for org.apache.wicket Component error.

Prototype

@Override
public final void error(final Serializable message) 

Source Link

Document

Registers an error feedback message for this component

Usage

From source file:au.com.scds.isis.viewer.wicket.ui.components.entity.properties.MyEntityPropertiesForm.java

License:Apache License

private void feedbackOrNotifyAnyRecognizedError(String recognizedErrorMessageIfAny,
        Component feedbackComponentIfAny) {
    if (recognizedErrorMessageIfAny == null) {
        return;//from w ww  .ja  va  2s.  co  m
    }

    if (feedbackComponentIfAny != null) {
        feedbackComponentIfAny.error(recognizedErrorMessageIfAny);
    }
    getMessageBroker().addWarning(recognizedErrorMessageIfAny);

    // we clear the abort cause because we've handled rendering the
    // exception
    getTransactionManager().getTransaction().clearAbortCause();
}

From source file:com.evolveum.midpoint.web.component.input.UploadDownloadPanel.java

License:Apache License

private void initLayout(final boolean isReadOnly) {
    final FileUploadField fileUpload = new FileUploadField(ID_INPUT_FILE);
    Form form = this.findParent(Form.class);
    fileUpload.add(new AjaxFormSubmitBehavior(form, "change") {
        @Override//ww w.  j  a va  2s .  co  m
        protected void onSubmit(AjaxRequestTarget target) {
            super.onSubmit(target);
            Component input = getInputFile();
            try {
                FileUpload uploadedFile = getFileUpload();
                updateValue(uploadedFile.getBytes());
                LOGGER.trace("Upload file success.");
                input.success(getString("UploadPanel.message.uploadSuccess"));
            } catch (Exception e) {
                LOGGER.trace("Upload file error.", e);
                input.error(getString("UploadPanel.message.uploadError") + " " + e.getMessage());
            }
        }
    });
    fileUpload.setOutputMarkupId(true);
    add(fileUpload);

    final AjaxDownloadBehaviorFromStream downloadBehavior = new AjaxDownloadBehaviorFromStream() {

        @Override
        protected InputStream initStream() {
            return getStream();
        }
    };
    add(downloadBehavior);

    add(new AjaxSubmitButton(ID_BUTTON_DOWNLOAD) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            downloadPerformed(downloadBehavior, target);
        }
    });

    add(new AjaxSubmitButton(ID_BUTTON_DELETE) {

        @Override
        protected void onSubmit(AjaxRequestTarget target, Form<?> form) {
            removeFilePerformed(target);
        }
    });

    add(new VisibleEnableBehaviour() {
        @Override
        public boolean isVisible() {
            return !isReadOnly;

        }

    });
}

From source file:com.evolveum.midpoint.web.component.input.UploadDownloadPanel.java

License:Apache License

public void uploadFilePerformed(AjaxRequestTarget target) {
    Component input = get(ID_INPUT_FILE);
    try {/*from w  ww  . ja  va  2  s .  c  om*/
        FileUpload uploadedFile = getFileUpload();
        updateValue(uploadedFile.getBytes());
        LOGGER.trace("Upload file success.");
        input.success(getString("UploadPanel.message.uploadSuccess"));
    } catch (Exception e) {
        LOGGER.trace("Upload file error.", e);
        input.error(getString("UploadPanel.message.uploadError") + " " + e.getMessage());
    }
}

From source file:com.evolveum.midpoint.web.component.input.UploadDownloadPanel.java

License:Apache License

public void removeFilePerformed(AjaxRequestTarget target) {
    Component input = get(ID_INPUT_FILE);
    try {//  w w  w . j ava2  s. c om
        updateValue(null);
        LOGGER.trace("Remove file success.");
        input.success(getString("UploadPanel.message.removeSuccess"));
    } catch (Exception e) {
        LOGGER.trace("Remove file error.", e);
        input.error(getString("UploadPanel.message.removeError") + " " + e.getMessage());
    }
}

From source file:gr.interamerican.wicket.utils.WicketUtils.java

License:Open Source License

/**
 * Triggers error on a component.//www.  ja v  a2  s .  c om
 * 
 * @param component
 *        Component on which error is triggered.  
 * @param resourceKey
 *        Resource key for the resource message. The resource key must be
 *        relevant to the component.
 */
public static void error(Component component, String resourceKey) {
    StringResourceModel model = new StringResourceModel(resourceKey, component, null);
    String message = model.toString();
    component.error(message);
}

From source file:org.apache.isis.viewer.wicket.ui.components.entity.properties.EntityPropertiesForm.java

License:Apache License

private void feedbackOrNotifyAnyRecognizedError(String recognizedErrorMessageIfAny,
        Component feedbackComponentIfAny) {
    if (recognizedErrorMessageIfAny == null) {
        return;/*w w w .j a v a  2 s . c o  m*/
    }

    if (feedbackComponentIfAny != null) {
        feedbackComponentIfAny.error(recognizedErrorMessageIfAny);
    }
    getMessageBroker().addWarning(recognizedErrorMessageIfAny);

    // we clear the abort cause because we've handled rendering the exception
    getTransactionManager().getTransaction().clearAbortCause();
}

From source file:org.obiba.onyx.webapp.OnyxApplication.java

License:Open Source License

public void onUnauthorizedInstantiation(Component component) {
    // If there is a sign in page class declared, and the unauthorized component is a page, but it's not the sign in
    // page// w w  w  .j a v a 2 s.  com
    if (component instanceof Page) {
        if (!OnyxAuthenticatedSession.get().isSignedIn()) {
            // Redirect to intercept page to let the user sign in
            throw new RestartResponseAtInterceptPageException(LoginPage.class);
        }
        // User is signed in but doesn't have the proper access rights. Display error and redirect accordingly.
        throw new RestartResponseAtInterceptPageException(AccessDeniedPage.class);

    }
    // The component was not a page, so show an error message in the FeedbackPanel of the page
    component.error("You do not have sufficient privileges to see this component.");
    throw new UnauthorizedInstantiationException(component.getClass());
}

From source file:org.opensingular.lib.wicket.util.util.WicketEventUtils.java

License:Apache License

public static void addErrorMessage(Component component, String messageKey, IModel<?> messageModel) {
    if (messageKey != null && component != null) {
        component.error(new StringResourceModel(messageKey, messageModel).getString());
    }//from   w w w.  j a va 2 s.  c  o  m
    logger.error("Obrigatrio informar component e messageKey em addErrorMessage, ignorando chamada...");
}

From source file:org.projectforge.web.wicket.AbstractForm.java

License:Open Source License

public void addComponentError(final Component component, final String msgKey) {
    component.error(getString(msgKey));
}