if you add a private variable that is imodel you have to detach it
yourself, perhaps that is your problem. you do this by overriding
ondetach() { field.detach(); super.ondetach(); }

-igor

On Fri, Feb 13, 2009 at 1:36 AM, pieter claassen <[email protected]> wrote:
> Ok, feedback on my own problem. It seems that if you create a private
> variable and assign an IModel to it, then access it from within the
> onClick() method in a listview, that it doesn't always work. You have to
> explicitly add the model to the Link constructor for this to work.
>
> It seems that the approach below doesn't always work in wicket.
>
> Thanks for the feedback so far.
> Pieter
>
> On Thu, Feb 12, 2009 at 11:20 PM, pieter claassen 
> <[email protected]>wrote:
>
>> 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}
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to