Just to make sure I understand this correctly.
1. Line 2: By storing an IModel mywebmodel that nulls the object reference
onDetach(), on my webpage, is ok for serialiazation?
2. Line 8: When I cast the IModel to MyObject, is there a way to make this
more safe at compile time?
3. Line 8: object is a database object in a field on MyObject. The fact that
I assign a reference to it in a local variable, does that mean this object
is going to be serialized with the page? What is actually being serialized
(the java, the html, bytecode?)
4. Line 9: Rather than call EditWebPage with a generic IModel and do the
runtime cast thing, I subclassed IModel into a number of webmodels such as
ObjectModel implements IModel. This creates more programming work but at
least provides some type safety during compile time. Is this the recommended
way to go or is there a better way?
1 public class MyWebPage extends WebPage{
2 private final IModel mywebmodel;
3 public MyWebPage(IModel model){
4 mywebmodel=model;
5 setModel(new CompoundPropertyModel(mywebmodel);
6 add(new Link("edit"){
7 public void onClick(){
8 MyObject object=(MyObject) mywebmodel.getModelObject().getChild();
9 setResponsePage(new EditWebPage(new IModel(object)));
10 }
11 }
12}
13}