On Wed, Apr 23, 2008 at 10:06 PM, Ned Collyer <[EMAIL PROTECTED]> wrote:
>
> Hi I have the following, and its resulting in 2x calls to the load on my
> model - which confuses me.
>
> My panel has the following in its constructor.
>
> setModel(new CompoundPropertyModel(new LoadableDetachableModel() {
> protected Object load() {
> return featureService.get(docRef);
> }
> }));
>
>
> In my test I have:
>
>
> expect(mockFeatureService.get(testFeature.getDocRef())).andReturn(testFeature);
> replay(mockFeatureService);
>
> applicationContext.putBean("featureService", mockFeatureService);
>
> wicketTester.startPanel(new TestPanelSource() {
> public Panel getTestPanel(String panelId) {
> return new TestFeatureShowPanel(panelId, testFeature.getDocRef());
> }
> });
>
> wicketTester.assertLabel("panel:title", testFeature.getTitle());
>
> verify(mockFeatureService);
>
> When I run this through a jetty server I get 1 call to the "load" method of
> my TestFeature model.
>
> When I run the test I get 2 calls to the load method. The 2nd seems to be
> triggered from the assertLabel call. If I have many assertLabel calls -
> then its still called only twice. Ie, more assertLabels do no call "load"
> again.
>
> Any ideas why?
>
The first call to load happens during rendering. When rendering is
done, your model is detached. Then, the call to assertLabel() forces
the model to be loaded again. Then, subsequent calls to assertLabel()
would not require a load because the model hasn't been detached.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]