yes, because you do not pass it between pages.
the problem really is that an anonymous class dangles a reference to the
parent. so if you pass an anon model created in page A to page B that model
still has a reference to page A so your session is a bit bigger because page
B always has a reference to page A.
-igor
On 10/12/07, marcus dickerhof <[EMAIL PROTECTED]> wrote:
>
> Hi,
> here comes my example:
>
> class MyWizard extends Wizard{
>
> private String tempfile;
>
> ...
>
> private final class Step1 extends WizardStep {
> //uploads file to some temp-folder + sets the tempfile name
> }
>
> private final class Step2 extends WizardStep {
> //Shows a summary Page + confirm button +
> //a link to delete the temp file that was uploaded in Step1
> public Step2(){
> ......
> --> is the following line ok???
> add(new Label("file", new PropertyModel(MyWizard.this, "tempfile" )
> )
> );
> add(new Link("delete")
> {
>
> public void onClick()
> {
>
> final File file = new File( MyWizard.this.tempfile );
> Files.remove(file);
> MyWizard.this.info("Deleted " + file);
>
> }
>
> });
>
>
>
> }
>
> }
>
>
> }
>
> Thanks!
> -Marcus
>
>
>
> 2007/10/12, Igor Vaynberg <[EMAIL PROTECTED]>:
> >
> > it is still an issue if you pass such a model between pages. i dont see
> > why
> > you would need an anonymous model instance.
> >
> > -igor
> >
> >
> > On 10/12/07, marcus dickerhof <[EMAIL PROTECTED]> wrote:
> > >
> > > Hi,
> > > I am quite new to wicket, and I want to avoid making serious mistakes
> > :-)
> > > On the Bestpractices and gotachs page:
> > > http://cwiki.apache.org/WICKET/best-practices-and-gotchas.html
> > > I found the following statement from Martijn Dashorst:
> > >
> > > --START
> > > The other thing to avoid is anonymous or nested instances of IModel.
> > > Usually
> > > you share an instance of a model between two page instances. If you
> > create
> > > an anonymous or nested instance of IModel, then you automatically get
> a
> > > 'this' reference to the class that surrounds it. This will usually be
> > the
> > > page, but can also be the form or a listview. Anyway, because the
> > > reference
> > > is /final/, you will copy that reference to the old page, with the
> model
> > > to
> > > the new page, thus duplicating the component tree (it gets versioned
> > > etc.).
> > > This will eventually lead to OutOfMemoryError.
> > >
> > > Search in the mailinglist for outofmemoryerror for other descriptions
> of
> > > this behaviour. I doubt that I have done the subject justice.
> > >
> > > --END
> > >
> > > Is this still an issue? And how would I do a
> > > workaround? Where can I find more infos concerning this problem?
> > >
> > >
> > > Thanks a lot!
> > >
> > > Best regards
> > > Marcus
> > >
> >
>