You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Chris <ch...@gmx.at> on 2015/04/22 04:48:44 UTC

Browser back - reload page/panel

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-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Browser back - reload page/panel

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

Yes. #load() method will be called exactly once per request.
Ajax request is still a request.

Martin Grigorov
Wicket Training and Consulting
https://twitter.com/mtgrigorov

On Fri, Apr 24, 2015 at 2:18 AM, Chris <ch...@gmx.at> wrote:

> Hi Martin,
>
> I am using the LOM as follows in a page constructor. When a subcomponent
> of this page (list item) is clicked, some part of the page is reloaded via
> ajax (not the whole page).
> In this case the method #service.retrieveList() is called. From your note
> I would assume that the method should not be called as the list should be
> cached? In my case, the method is called as soon as some part of the page
> is reloaded via Ajax. Should this be the case?
>
> Thanks for your help, Chris
>
>
> IModel<List<SomeType>> poisModel = new ListModel<SomeType>() {
>          @Override
>          public List<SomeType> getObject() {
>              return service.retrieveList();
>          }
> }
>
>
> > Am 23.04.2015 um 07:47 schrieb Martin Grigorov <mg...@apache.org>:
> >
> > 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" <ch...@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 <se...@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 <se...@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 <ch...@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 <
> mgrigorov@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 <ch...@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-unsubscribe@wicket.apache.org
> >>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
> >>>>>>>>
> >>>>>>>>
> >>>>>>
> >>>>>>
> >>>>>>
> ---------------------------------------------------------------------
> >>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >>>>>> For additional commands, e-mail: users-help@wicket.apache.org
> >>>>>>
> >>>>>>
> >>>>
> >>>>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Browser back - reload page/panel

Posted by Chris <ch...@gmx.at>.
Hi Martin,

I am using the LOM as follows in a page constructor. When a subcomponent of this page (list item) is clicked, some part of the page is reloaded via ajax (not the whole page).
In this case the method #service.retrieveList() is called. From your note I would assume that the method should not be called as the list should be cached? In my case, the method is called as soon as some part of the page is reloaded via Ajax. Should this be the case?

Thanks for your help, Chris


IModel<List<SomeType>> poisModel = new ListModel<SomeType>() {
         @Override
         public List<SomeType> getObject() {
             return service.retrieveList();
         }
}


> Am 23.04.2015 um 07:47 schrieb Martin Grigorov <mg...@apache.org>:
> 
> 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" <ch...@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 <se...@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 <se...@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 <ch...@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 <mgrigorov@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 <ch...@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-unsubscribe@wicket.apache.org
>>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>> 
>>>>>>>> 
>>>>>> 
>>>>>> 
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>> 
>>>>>> 
>>>> 
>>>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>> 
>> 


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


Re: Browser back - reload page/panel

Posted by Martin Grigorov <mg...@apache.org>.
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" <ch...@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 <se...@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 <se...@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 <ch...@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 <mgrigorov@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 <ch...@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-unsubscribe@wicket.apache.org
> >>>>>> For additional commands, e-mail: users-help@wicket.apache.org
> >>>>>>
> >>>>>>
> >>>>
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >>>> For additional commands, e-mail: users-help@wicket.apache.org
> >>>>
> >>>>
> >>
> >>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Browser back - reload page/panel

Posted by Chris <ch...@gmx.at>.
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 <se...@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 <se...@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 <ch...@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 <mg...@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 <ch...@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-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>> 
>>>>>> 
>>>> 
>>>> 
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>> 
>>>> 
>> 
>> 


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


Re: Browser back - reload page/panel

Posted by Sebastien <se...@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 <se...@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 <ch...@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 <mg...@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 <ch...@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-unsubscribe@wicket.apache.org
> >>>> For additional commands, e-mail: users-help@wicket.apache.org
> >>>>
> >>>>
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
>
>

Re: Browser back - reload page/panel

Posted by Chris <ch...@gmx.at>.
Hi Sebastian,

thanks - but if the page has many subcomponents that consume the model then there would be many subsequent calls? The service call might be expensive, isn’t it?
Is there another solution next to loadable detachable model? I could use a static model if the model does not change during a request…

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);
    }
}));

Thanks, Chris

> Am 22.04.2015 um 23:16 schrieb Sebastien <se...@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 <ch...@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 <mg...@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 <ch...@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-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>> 
>>>> 
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>> 
>> 


Re: Browser back - reload page/panel

Posted by Sebastien <se...@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 <ch...@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 <mg...@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 <ch...@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-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: Browser back - reload page/panel

Posted by Chris <ch...@gmx.at>.
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 <mg...@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 <ch...@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-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>> 
>> 


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


Re: Browser back - reload page/panel

Posted by Martin Grigorov <mg...@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 <ch...@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-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>