Example usage for org.apache.wicket MarkupContainer getDefaultModel

List of usage examples for org.apache.wicket MarkupContainer getDefaultModel

Introduction

In this page you can find the example usage for org.apache.wicket MarkupContainer getDefaultModel.

Prototype

public final IModel<?> getDefaultModel() 

Source Link

Document

Gets the model.

Usage

From source file:org.hippoecm.frontend.plugins.jquery.upload.single.BinaryContentEventLogger.java

License:Apache License

/**
 * Find first component with backing JcrNodeModel and fire an upload event.
 *
 * @param component top component in component chain
 * @param category workflow category e.g. cms
 * @param type type of workflow e.g. image or resource
 * @param action name of the workflow action e.g. upload or crop
 *///from   ww w.  j av a  2s  . co  m
public static void fireUploadEvent(final MarkupContainer component, final String category, final String type,
        final String action) {
    MarkupContainer markupContainer = component;
    while (markupContainer != null) {
        IModel<?> model = markupContainer.getDefaultModel();
        if (model instanceof JcrNodeModel) {
            final JcrNodeModel nodeModel = (JcrNodeModel) model;
            final Node subjectNode = nodeModel.getNode();
            try {
                Session session = subjectNode.getSession();
                session.save();
                fireBinaryChangedEvent(subjectNode, category, type, action);
            } catch (RepositoryException e) {
                log.error("Error saving session", e);
            }
            return;
        }
        markupContainer = markupContainer.getParent();
    }
}