Interface IModelReference<T>

  • Type Parameters:
    T - the type of the object for the model
    All Superinterfaces:
    org.apache.wicket.util.io.IClusterable, org.apache.wicket.model.IDetachable, IObservable, Serializable
    All Known Implementing Classes:
    ModelReference

    public interface IModelReference<T>
    extends org.apache.wicket.model.IDetachable, IObservable
    Service interface for sharing models. When a model is shared between plugins and it is subject to change, it should be wrapped in an IModelReference service. The service is usually available under the configuration key 'wicket.model'.

    This service is observable as well, so it is possible to receive model change events by registering an IObserver with the service as the observable. An IModelReference.IModelChangeEvent should be sent whenever setModel(org.apache.wicket.model.IModel<T>) is invoked.

    The default implementation ModelReference, takes care of sending the events.

    Model services should be registered before any of the plugins that uses them is started. This makes it easier to create plugins that consume models (they don't need to register service trackers). Since generally a model is injected into a new plugin cluster, this is usually quite a natural thing to do.

    • Method Detail

      • getModel

        org.apache.wicket.model.IModel<T> getModel()
        Retrieve the current model of the model service
        Returns:
        the model
      • setModel

        void setModel​(org.apache.wicket.model.IModel<T> model)
        Update the model of the service. Observers will be notified with an IModelReference.IModelChangeEvent.
        Parameters:
        model - the new model