As models are nested this is not possible with the current setup. If a model nests another model, the nesting model is responsible for calling detach on the nested model. Multiple models may nest the same model.

So the best thing to do for now is to have some flag to see if you're already detached. In getObject the flag is cleared. For most models however, it should not matter if they're called multiple times; the typical thing you do in detach is set a field to null.

Regards,
   Erik.


James Carman wrote:
No, he means *all* models.  The idea would be that Wicket would look
for fields of type IModel (or its descendants) on components/pages.
If it sees one, it would automatically detach it.

On Mon, Jul 13, 2009 at 3:47 AM, Vladimir K<koval...@gmail.com> wrote:
Martijn,

you probably mean how chained models would be detached. So instead of
propagating detach in IChainedModel they would be detached automatically?

Is there a vision how it would be accomplished?


Martijn Dashorst wrote:
Automatic detachment is one of the things we're looking into for 1.5 or
1.6

Martijn

On Fri, Jul 10, 2009 at 12:47 PM, James
Carman<jcar...@carmanconsulting.com> wrote:
Perhaps there could be some sort of registry for models that need to
be detached.  Then, after rendering, they're all detached as part of
the request cycle?

On Fri, Jul 10, 2009 at 4:00 AM, Martijn
Dashorst<martijn.dasho...@gmail.com> wrote:
If you share a model between components, then yes–each component will
call detach on the model. That's encapsulation for you: one component
doesn't know about another component, so it can't know that its model
was detached.

Martijn

On Fri, Jul 10, 2009 at 9:41 AM, Ian MacLarty<ian.macla...@gmail.com>
wrote:
I put a breakpoint on the detach method of my model and had a look at
the Components whose detach methods were called higher up in the stack
trace.  It looks like the detach method on the model is being called
for every component on the page.  All the components link to the same
underlying model via a CompoundPropertyModel, so I guess lots of calls
to the detach method of the model should be expected?

Ian.

On Fri, Jul 10, 2009 at 5:17 PM, Eelco
Hillenius<eelco.hillen...@gmail.com> wrote:
It's fine if a model if detached multiple times in a request, but
hundreds for a single model sounds suspicious. Try to trace what
components fire the detach method and see if there's anything weird
with that.

Eelco

On Thu, Jul 9, 2009 at 11:21 PM, Ian MacLarty<ian.macla...@gmail.com>
wrote:
Hi,

I noticed that my IDetachable model is being detached many times
(hundreds) for each request.  Is that something to worry about, or is
it just because the detach method is called for each component that
points to this model?

Ian.


--

Erik van Oosten
http://day-to-day-stuff.blogspot.com/



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

Reply via email to