See the implementation of LoadableDetachableModel. It caches the result for
the request lifetime. That's why it calls getObject() just once
On Apr 23, 2015 1:56 AM, "Chris" <chris...@gmx.at> wrote:

> Hi Sebastian,
>
> With „static“ I mean something as follows: model = new
> ListModel<SomeType>(service.retrieve());
>
> I do not quite understand why the subsequent calls do not matter when
> using a LDM.
> If I use an LDM and a component of the page uses this model (e.g. creating
> a new Panel) then the service method is called again and this has a
> negative impact on performance if the database is hit all the time. With
> the line above this does not happen.
>
> thanks for your feedback!
> Chris
>
>
> > Am 23.04.2015 um 00:30 schrieb Sebastien <seb...@gmail.com>:
> >
> > Hi Chris,
> >
> > thanks - but if the page has many subcomponents that consume the model
> then
> >> there would be many subsequent calls?
> >
> >
> > To getObject, yes. But if you use a (shared) LDM it doesn't matter.
> >
> >
> >> The service call might be expensive, isn’t it?
> >>
> >
> > Yes, probably.
> >
> >
> >> Is there another solution next to loadable detachable model?
> >
> >
> > It depends of your use case, you can do what you want with models
> > (including writing yours of course)
> > But for your use case, a LDM should suit...
> >
> >
> >> I could use a static model if the model does not change during a
> request…
> >>
> >
> > Not sure what you mean by static model...
> >
> >
> >>
> >> You said that the #getObject should not be overridden in this way:
> >> When to recommend it? The example below uses this approach:
> >>
> >> personForm.add(new RequiredTextField("personName", new Model() {
> >>    @Override
> >>    public Object getObject() {
> >>        return person.getName();
> >>    }
> >>
> >>    @Override
> >>    public void setObject(Serializable object) {
> >>        person.setName((String) object);
> >>    }
> >> }));
> >>
> >
> > The example is correct... There is a difference between
> > service.retrieveList and person.getName(): the latest being is an atomic
> > call while the first is potentially time consuming.
> > That's exactly one of the two reason why the LDM as been written :) (the
> > second being it is automatically detached...)
> >
> >
> >>
> >> Thanks, Chris
> >>
> >>> Am 22.04.2015 um 23:16 schrieb Sebastien <seb...@gmail.com>:
> >>>
> >>> Hi Chris,
> >>>
> >>> #getObject is potentially called often, yes. You should never override
> >>> #getObject() like this....
> >>> A dynamic model is a LoadableDetachableModel. Overrides #load and it
> will
> >>> be called only once by server request, at each server request (that
> >>> consumes the model, of course).
> >>>
> >>> Hope this helps,
> >>> Sebastien.
> >>>
> >>>
> >>> On Wed, Apr 22, 2015 at 11:05 PM, Chris <chris...@gmx.at> wrote:
> >>>
> >>>> Martin, thanks for the tip.
> >>>>
> >>>> I would like to use some dynamic List Model, but not a detachable one
> >> and
> >>>> put following in the page’s initialization method:
> >>>>
> >>>> IModel<List<SomeType>> poisModel = new ListModel<SomeType>() {
> >>>>           @Override
> >>>>           public List<SomeType> getObject() {
> >>>>               return service.retrieveList();
> >>>>           }
> >>>>
> >>>> Why is the service.retrieveList method called so often, I thought that
> >>>> this call should be only made once?
> >>>> Should I use another model?
> >>>>
> >>>> Thanks!
> >>>> Chris
> >>>>
> >>>>
> >>>>> Am 22.04.2015 um 07:58 schrieb Martin Grigorov <mgrigo...@apache.org
> >:
> >>>>>
> >>>>> Hi,
> >>>>>
> >>>>> Wicket disables caching for the pages [1] so going back will make a
> >>>> request
> >>>>> for re-render.
> >>>>> You should use dynamic models [2] to re-render the latest state.
> >>>>>
> >>>>>
> >>>>> 1.
> >>>>>
> >>>>
> >>
> https://github.com/apache/wicket/blob/822a1693c2d017478613321ae6fce40d519b24fa/wicket-core/src/main/java/org/apache/wicket/markup/html/WebPage.java#L205
> >>>>> 2.
> >>>>>
> >>>>
> >>
> https://cwiki.apache.org/confluence/display/WICKET/Working+with+Wicket+models#WorkingwithWicketmodels-DynamicModels
> >>>>>
> >>>>> Martin Grigorov
> >>>>> Wicket Training and Consulting
> >>>>> https://twitter.com/mtgrigorov
> >>>>>
> >>>>> On Wed, Apr 22, 2015 at 5:48 AM, Chris <chris...@gmx.at> wrote:
> >>>>>
> >>>>>> Hi all,
> >>>>>>
> >>>>>> how is it possible to refresh a page or panel on browser back? If
> the
> >>>> user
> >>>>>> deletes an item and clicks on browser back to go to the last page,
> it
> >> is
> >>>>>> still displayed which should not be the case.
> >>>>>>
> >>>>>> Thanks a lot,
> >>>>>> Chris
> >>>>>>
> ---------------------------------------------------------------------
> >>>>>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> >>>>>> For additional commands, e-mail: users-h...@wicket.apache.org
> >>>>>>
> >>>>>>
> >>>>
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> >>>> For additional commands, e-mail: users-h...@wicket.apache.org
> >>>>
> >>>>
> >>
> >>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

Reply via email to