Here's a start, please anyone correct me if I've made any mistakes...

public class ListLDM extends LoadableDetachableModel<List> {
 
        private String id;
 
        public ListLDM(List l, String id) {
                //constructor with primed model
                super(l);
                this.id = id;
        }
 
        public ListLDM(String id) {
                //constructor with empty model
                this.id = id;
        }

        @Override
        protected List load() {
                return service.getList(id);
        }

}



From:   John Owen <jo...@globalscape.com>
To:     "users@wicket.apache.org" <users@wicket.apache.org>
Date:   02/28/2011 05:35 PM
Subject:        RE: Perfomance of IDataProvider



An example with a list would be quite useful.

Regards

-----Original Message-----
From: mzem...@osc.state.ny.us [mailto:mzem...@osc.state.ny.us] 
Sent: Monday, February 28, 2011 3:10 PM
To: users@wicket.apache.org
Subject: Re: Perfomance of IDataProvider

If I understand where you are going I completely agree the example is a 
little misleading.  Some ways to think about it differently... 

"id" is synonymous with "a small sub-set of the entire result-set which 
can be used to rehydrate the detached model"

The model is the data you want to provide to a repeater for instance, so 
this can be a single Contact model (one query for each row) or a 
ContactList (one query per page with pagination).  Retrieving a list 
instead of each contact individually would be more efficient.

If you need an example let me know...




From:   Juansoft <andresnet2...@yahoo.es>
To:     users@wicket.apache.org
Date:   02/28/2011 03:53 PM
Subject:        Re: Perfomance of IDataProvider



First render thanks for your replies.

@vov: If i use this:

  public IModel<Entity> model(Entity entity)
  {
    return new Model<Entity>(entity);
 } 

In this case the memory footprint of the session grows because you return
Model object that is not a transient object(or this is what I've read in
wicket documentation...!!) .  ¿This means that if you dataview have 100 
rows
you have 100 Model<Entity> stored in your session?

¿To avoid this do not exist LoadableDetachableModel what is detached after
page rendering?


@James Carman:

This is the aspect of the most LoadableDetachableModel used in DataView
examples. Specifically in wicket official examples. For each row in 
DataView
this create new DetachableContactModel , store his ID. After in method
populateItem of Dataview, getModelObject() call result in direct call to
DetachableContactModel.load() that again return object to a database.

Using hibernate this object is cached (or so I have understood), but if 
use
hand made DAO (like me) that simply query and return a POJO populated this
result in more database conections and querys! Am I right?


public class DetachableContactModel extends LoadableDetachableModel
{
    private long id;
 
      protected ContactsDatabase getContactsDB()
       {

        return DatabaseLocator.getDatabase();
       }

    /**
     * @param c
     */
    public DetachableContactModel(Contact c)
    { 
        this(c.getid())
    }

    /**
     * @param id
     */
    public DetachableContactModel(long id)
    {
        if (id == 0)
        {
            throw new IllegalArgumentException();
        }
        this.id = id;
    }

    /**
     * @see java.lang.Object#hashCode()
     */
    public int hashCode()
    {
        return Long.valueOf(id).hashCode();
    }

    /**
     * used for dataview with ReuseIfModelsEqualStrategy item reuse 
strategy
     *
     * @see org.apache.wicket.markup.repeater.ReuseIfModelsEqualStrategy
     * @see java.lang.Object#equals(java.lang.Object)
     */
    public boolean equals(final Object obj)
    {
        if (obj == this)
        {
            return true;
        }
        else if (obj == null)
        {
            return false;
        }
        else if (obj instanceof DetachableContactModel)
        {
            DetachableContactModel other = (DetachableContactModel)obj;
            return other.id == this.id;
        }
        return false;
    }

    /**
     * @see org.apache.wicket.model.LoadableDetachableModel#load()
     */
    @Override
    protected Object load()
    {
        // loads contact from the database 
        return getContactsDB().get(id); 
    }
 
 
}



-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Perfomance-of-IDataProvider-tp3325777p3328345.html


Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org






Notice: This communication, including any attachments, is intended solely 
for the use of the individual or entity to which it is addressed. This 
communication may contain information that is protected from disclosure 
under State and/or Federal law. Please notify the sender immediately if 
you have received this communication in error and delete this email from 
your system. If you are not the intended recipient, you are requested not 
to disclose, copy, distribute or take any action in reliance on the 
contents of this information.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org






Notice: This communication, including any attachments, is intended solely 
for the use of the individual or entity to which it is addressed. This 
communication may contain information that is protected from disclosure 
under State and/or Federal law. Please notify the sender immediately if 
you have received this communication in error and delete this email from 
your system. If you are not the intended recipient, you are requested not 
to disclose, copy, distribute or take any action in reliance on the 
contents of this information.

Reply via email to