Matijn, thank you for your hint.

I searched on your blog, http://martijndashorst.com/blog/, and Eelco's,
http://day-to-day-stuff.blogspot.com/, but must have searched for the wrong
thing ("transient", "entity", "SerializableChecker")...

Anyways, I'd like to do what you suggest, but have a few question:

I guess I have to provide my own implementation of IObjectStreamFactory in
order to force my subclass of SerializableChecker to run (in development
mode). For this, do I subclass IObjectStreamFactory.DefaultObjectStreamFactory
or WicketObjectStreamFactory?

Where would I install this custom IObjectStreamFactory?

As to SerializableChecker itself, I think my version simply has to look for
models in

private void check(Object obj)
{
  if (obj == null)
  {
    return;
  }
  Class<?> cls = obj.getClass();
  nameStack.add(simpleName);
  traceStack.add(new TraceSlot(obj, fieldDescription));
  if (!(obj instanceof Serializable) && (!Proxy.isProxyClass(cls)))
  {
    throw new WicketNotSerializableException(
    toPrettyPrintedStack(obj.getClass().getName()), exception);
  }
  // NEW
  if (obj instanceof LoadableDetachableModel) {
    LoadableDetachableModel m = (LoadableDetachableModel)m;
    if (m.isAttached())
    {
      throw new IllegalStateException("Model not detached!");
    }
  }
  // ...

Regards,
Kaspar

On 29.08.2008, at 08:20, Martijn Dashorst wrote:

you could extend the serializerchecker to check for underached models.
We did something similar checking for non-transient Entity objects.
Iirc the code is either on my blog or Eelco's blog.

Martijn

On 8/28/08, Igor Vaynberg <[EMAIL PROTECTED]> wrote:
no, there is no easy way to "assert" that any model has been detached,
because they do not keep a flag.

in 1.5 we will implement it so that all fields of a component that
implement idetachable are detached in the end of request via
reflection, so that should help somewhat.

-igor

On Thu, Aug 28, 2008 at 1:57 PM, Kaspar Fischer <[EMAIL PROTECTED]>
wrote:
Is there an easy way to assert that all models are detached at the end of
the
request?

It does not look so easy to check this as models do not have common base
class
where one could register them for a check...

I often use an additional model in a component and store it as a member
field;
if I forgot to detach() this model in the onDetach() handler, I would have
a
"dangling" model. That caused me quite some trouble once and I want to
avoid
it in the future.

Thanks,
Kaspar

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.3.4 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to