Package org.apache.wicket.model

Examples of org.apache.wicket.model.IModel


   *
   * @return The backing model object
   */
  public final Object getModelObject()
  {
    final IModel model = getModel();
    if (model != null)
    {
      // Get model value for this component.
      return model.getObject();
    }
    else
    {
      return null;
    }
View Full Code Here


   * @return True if the given component's model is the same as this component's model.
   */
  public final boolean sameInnermostModel(final IModel model)
  {
    // Get the two models
    IModel thisModel = getModel();
    IModel thatModel = model;

    // If both models are non-null they could be the same
    if (thisModel != null && thatModel != null)
    {
      return getInnermostModel(thisModel) == getInnermostModel(thatModel);
View Full Code Here

   *            The model
   * @return This
   */
  public Component setModel(final IModel model)
  {
    IModel prevModel = getModelImpl();
    // Detach current model
    if (prevModel != null)
    {
      prevModel.detach();
    }

    if (prevModel instanceof IWrapModel)
    {
      prevModel = ((IWrapModel)prevModel).getWrappedModel();
View Full Code Here

   *            The object to set
   * @return This
   */
  public final Component setModelObject(final Object object)
  {
    final IModel model = getModel();

    // Check whether anything can be set at all
    if (model == null)
    {
      throw new IllegalStateException(
        "Attempt to set model object on null model of component: " + getPageRelativePath());
    }

    // Check authorization
    if (!isActionAuthorized(ENABLE))
    {
      throw new UnauthorizedActionException(this, ENABLE);
    }

    // Check whether this will result in an actual change
    if (!getModelComparator().compare(this, object))
    {
      modelChanging();
      model.setObject(object);
      modelChanged();
    }

    return this;
  }
View Full Code Here

  /**
   * Detaches the model for this component if it is detachable.
   */
  protected void detachModel()
  {
    IModel model = getModelImpl();
    if (model != null)
    {
      model.detach();
    }
    // also detach the wrapped model of a component assigned wrap (not
    // inherited)
    if (model instanceof IWrapModel && !getFlag(FLAG_INHERITABLE_MODEL))
    {
View Full Code Here

   *            The model
   * @return The innermost (most nested) model
   */
  protected final IModel getInnermostModel(final IModel model)
  {
    IModel nested = model;
    while (nested != null && nested instanceof IWrapModel)
    {
      final IModel next = ((IWrapModel)nested).getWrappedModel();
      if (nested == next)
      {
        throw new WicketRuntimeException("Model for " + nested + " is self-referential");
      }
      nested = next;
View Full Code Here

    {
      // Get model
      // Don't call the getModel() that could initialize many inbetween
      // completely useless models.
      // IModel model = current.getModel();
      IModel model = current.getModelImpl();

      if (model instanceof IWrapModel && !(model instanceof IComponentInheritedModel))
      {
        model = ((IWrapModel)model).getWrappedModel();
      }
View Full Code Here

  /**
   * @see org.apache.wicket.Component#setModel(org.apache.wicket.model.IModel)
   */
  public Component setModel(final IModel model)
  {
    final IModel previous = getModelImpl();
    super.setModel(model);
    if (previous instanceof IComponentInheritedModel)
    {
      visitChildren(new IVisitor()
      {
        public Object component(Component component)
        {
          IModel compModel = component.getModel();
          if (compModel instanceof IWrapModel)
          {
            compModel = ((IWrapModel)compModel).getWrappedModel();
          }
          if (compModel == previous)
View Full Code Here

  /**
   * @see org.apache.wicket.Component#setModel(org.apache.wicket.model.IModel)
   */
  public Component setModel(final IModel model)
  {
    final IModel previous = this.model;
    super.setModel(model);
    if (previous instanceof IComponentInheritedModel)
    {
      visitChildren(new IVisitor()
      {
        public Object component(Component component)
        {
          IModel compModel = component.getModel();
          if (compModel instanceof IWrapModel)
          {
            compModel = ((IWrapModel)compModel).getWrappedModel();
          }
          if (compModel == previous)
View Full Code Here

          add(row);

          // we add our actual SelectOption component to the row
          Object value = it.next();
          String text = renderer.getDisplayValue(value);
          IModel model = renderer.getModel(value);
          row.add(new SimpleSelectOption("option", model, text));
        }
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.wicket.model.IModel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.