Component currently has this behavior.
/**
* Gets the backing model object; this is shorthand for
* getModel().getObject().
*
* @return The backing model object
*/
public final Object getModelObject()
{
final IModel model = getModel();
if (model != null)
{
// If this component has the root model
for a compound model
if (getFlag(FLAG_HAS_ROOT_MODEL))
{
// we need to return the
root model and not a property of the
// model
return
getRootModel(model).getObject(null);
}
// Get model value for this component
return model.getObject(this);
}
else
{
return null;
}
}
.which is a pain for me. If Component is looking for the root model is will
call getRootModel(model).getObject(null), passing in null to getObject. At
the other end of this call, the model in question receives null to its
getObject(Component component) method. Now, if I have my own special model,
which I do (yes, I know you have lots of Model types and I should never need
to make my own, call me crazy, but I thought I'd actually use the API for my
own specific purposes), and that model chucks its internal state upon a call
to detach, I need to retrieve that original state. I do that upon a call to
getObject() when the model knows it was last in the detached state. The
Application holds a cache of database ORM layer session factories for each
active web session, and the state of any transaction in progress for that
web session (if it has any). This is convenient as when the web session
itself is terminated, the Application will roll back any transaction in
progress, and void itself of the associated ORM session factory. On the
other hand, if a long running transaction is in progress, on a still valid
web session, then I need to retrieve that and use the ORM session to
reconstruct the model's internal state (based on an object id). Well, inside
the model, how am I to know the Application context I'm acting within? I
could store that, and hold it even through a detach, but in a clustered
environment I can't guarantee that the Application context I'm
reconstructing my state under is the same one under which I was detached
(the session might have been serialized and moved to another instance of the
cluster). No matter, I'll just grab the Component handed into
getObject(Component component) and ask it for its current Application. no,
I've been passed null, I can't do that. What else can I use given the IModel
API. well, nothing. I have no other reference back to the Application
context.
Please always hand in Component. If any particular implementation of
getObject() does not need it, that implementation may ignore it. I need it.
Why am I getting null?
Is there some other way around this problem?
Thanks in advance for any help you can give,
David Berkman
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user