or just new LDM() { load() { return getwhatever();}}
-igor
On 4/29/08, Hoover, William <[EMAIL PROTECTED]> wrote:
> // It solves your problem because the call to load will be made each
> time your view renders
> final LoadableDetachableModel articlesLoadableModel = new
> LoadableDetachableModel() {
> private static final long serialVersionUID = 1L;
>
> /**
> * [EMAIL PROTECTED]
> */
> @Override
> protected final Object load() {
> return new PropertyModel(YourPage.this, "articles");
> }
> };
> final ListView newsDetails = new ListView("newsDetails",
> articlesLoadableModel){
> private static final long serialVersionUID = 1L;
>
> /**
> * [EMAIL PROTECTED]
> */
> @Override
> protected final void populateItem(final ListItem item) {
> ...
> }
> };
> add(newsDetails);
>
> -----Original Message-----
> From: Andrew Broderick [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, April 29, 2008 2:19 PM
> To: '[email protected]'
> Subject: RE: getter called multiple times on PropertyModel with ListView
>
> Cannot instantiate LoadableDetachableModel directly .. it is abstract.
> Besides, how does it help solve the problem?
>
> Thanks
>
> -----Original Message-----
> From: Igor Vaynberg [mailto:[EMAIL PROTECTED]
> Sent: Tuesday, April 29, 2008 12:49 PM
> To: [email protected]
> Subject: Re: getter called multiple times on PropertyModel with ListView
>
> ListView newsDetails = new ListView("newsDetails", new
> LoadableDetachableModel(new PropertyModel(this, "articles")))
>
> -igor
>
> On Tue, Apr 29, 2008 at 10:46 AM, Andrew Broderick
> <[EMAIL PROTECTED]> wrote:
> > Hi,
> >
> > I have a page where I am using a PropertyModel to populate a
> ListView, so it will change when the underlying contents change:
> >
> > ListView newsDetails = new ListView("newsDetails", new
> PropertyModel(this, "articles"))
> > {
> > protected void populateItem(ListItem item)
> > {
> >
> > final NewsDetails nd = (NewsDetails)
> item.getModelObject();
> > item.add(new Label("articleDate",
> nd.getArticleDate()));
> > item.add(new Label("articleTime",
> nd.getArticleTime()));
> > item.add(new Label("newsShortDesc",
> nd.getNewsShortDesc()));
> > newsUrlLink.add(new Label("newsTitle",
> nd.getNewsTitle()));
> > item.add(newsUrlLink);
> > }
> > };
> > add(newsDetails);
> >
> > The page class, obviously, has a getter named getArticles():
> >
> >
> > public List<NewsDetails> getArticles()
> > {
> > ....
> > }
> >
> > However, this seems to get called multiple times when the listview is
> being populated, not just once at the beginning of each time the page is
> displayer. Why is this happening? It results in many more hits to the
> database than are necessary.
> >
> > Thanks,
> >
> > Andrew B
> >
> > _______________________________________________________
> >
> > The information in this email or in any file attached hereto is
> > intended only for the personal and confiden- tial use of the
> > individual or entity to which it is addressed and may contain
> > information that is propri- etary and confidential. If you are
> > not the intended recipient of this message you are hereby notified
> > that any review, dissemination, distribution or copying of this
> > message is strictly prohibited. This communica- tion is for
> > information purposes only and should not be regarded as an offer to
> > sell or as a solicitation of an offer to buy any financial product.
>
> > Email trans- mission cannot be guaranteed to be secure or error-
> > free. P6070214
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]