I'm new to Java and Wicket. My only previous experince with web applications
has been with Asp.net forms (not MVC). Please be patient; coming from the
postback event paradigm, I'm struggling to grasp the concepts in Wicket. In my
simple scenario, assume there is no AJAX. I need to build the model from a
database. If I use an LDM, on a postback Wicket calls to the database to
rebuild the model before updating it with the new values. But if I don't use an
LDM, Wicket will serialize the model in the PageMap. I would like to keep the
model 'in memory' long enough to process the postback to avoid unecessary calls
to the database, but release it when I have moved on to a different page. I
thought of something like this... In the LDM @Override
public Object load()
{
...somehow get the session.
if (session.getAttribute("PageAModel")!=null)
{
return (PageAModel)session.getAttribute("PageAModel");
}
else
{
PageAModel pageAModel = ...build from database.
session.setAttribute("PageAModel", PageAModel);
return pageAModel;
}
} Then in the Page... @Override
public void onSubmit()
{
PageAModel pageAModel=(PageAModel)session.getAttribute("PageAModel");
...update the database with PageAModel pageAModel =
(PageAModel)ldm.getObject();
... //removes the model from session?
session.setAttribute("PageAModel")=null;
this.setResponsePage(...);
} I suspect there is a better way to handle this. Can I avoid using an
LDM, but somehow remove the model from the PageMap after leaving the page?