Search in sources :

Example 1 with ChainingModel

use of org.apache.wicket.model.ChainingModel in project webanno by webanno.

the class ModelChangedVisitor method innermostModel.

private IModel<?> innermostModel(IModel<?> aModel) {
    IModel<?> nested = aModel;
    while (nested != null) {
        if (nested instanceof IWrapModel) {
            final IModel<?> next = ((IWrapModel<?>) nested).getWrappedModel();
            if (nested == next) {
                throw new WicketRuntimeException("Model for " + nested + " is self-referential");
            }
            nested = next;
        } else if (nested instanceof ChainingModel) {
            final IModel<?> next = ((ChainingModel<?>) nested).getChainedModel();
            if (nested == next) {
                throw new WicketRuntimeException("Model for " + nested + " is self-referential");
            }
            nested = next;
        } else {
            break;
        }
    }
    return nested;
}
Also used : IModel(org.apache.wicket.model.IModel) IWrapModel(org.apache.wicket.model.IWrapModel) WicketRuntimeException(org.apache.wicket.WicketRuntimeException) ChainingModel(org.apache.wicket.model.ChainingModel)

Aggregations

WicketRuntimeException (org.apache.wicket.WicketRuntimeException)1 ChainingModel (org.apache.wicket.model.ChainingModel)1 IModel (org.apache.wicket.model.IModel)1 IWrapModel (org.apache.wicket.model.IWrapModel)1