On 03/02/10 11:55, marioosh.net wrote:
Sorry for my poor english ;)

I have ListView and model like below. I need tabs to reload sometimes,
so my model is dynamic and get tabs from database.
But i see that something is wrong. When i want to get Tab object by
getModelObject() in populateItem method i suppoused that i got it
directly, but i see that all the times the getObject() method of model
is triggered making for all items new list (new db request) !

That's exactly what is supposed to happen, as getModelObject() is just a shorthand for getModel().getObject(). And in your getObject(), you do the database request.

If you need to avoid those database reloads, look into LoadableDetachableModels.

-- Thomas



How to get Tab objects for items without making wasting time database
request ???


                IModel model = new IModel() {
                        public Object getObject() {
                                System.out.println("getObject...");
                                ...
                                // getting list from DB
                                List<Tab>  list = ....;
                                return list;
                        }

                        public void setObject(Object object) {}
                        public void detach() {
                        }};
                
                ListView tabs = new ListView("tabs", model) {
                        @Override
                        protected void populateItem(ListItem item) {
                                item.getModelObject(); /*<------------- new 
list, and new list,
and new list...... :(
                        }
                };



--
-------------------------------------------------------------------
  Thomas Kappler                        thomas.kapp...@isb-sib.ch
  Swiss Institute of Bioinformatics         Tel: +41 22 379 51 89
  CMU, rue Michel Servet 1
  1211 Geneve 4
  Switzerland                              http://www.uniprot.org
-------------------------------------------------------------------

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

Reply via email to