Page model returning null

View: New views
3 Messages — Rating Filter:   Alert me  

Page model returning null

by Loren Cole :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I've got the following bits of code:

public HomePage(PageParameters parms) {
        this();
        Long accountId = parms.getLong("accountId");
        account = new ModelEntity(Account.class, accountId);
        setModel(account);
...

public class EditContactDetails extends Panel{
    public EditContactDetails(String id, final ModelEntity contact){
        super(id);
        Form form = new Form("form", new CompoundPropertyModel(contactObj)){
            @Override
            protected void onSubmit(){
                //do stuff

                //redraw the page
                HomePage hp = (HomePage) this.findPage();
                ModelEntity account = (ModelEntity)
parent.getInnermostModel();
                facade.logSevere(account.toString());
                hp.reloadAccount(account);
            }
        };
...

getInnermostModel() is returning null, instead of the model I set it to when
loading the page.  This all used to work until I added a panel to hierarchy
above EditContactDetails and I'm not sure why I can't get my hands on the
model now.

I'm using wicket 1.3.5.  Are there circumstances where findPage() would
return a new instance of HomePage?  Logging tells me that HomePage's model
does not contain null at the time it is set, and I'm not explicitly setting
it anywhere else, is there some trickery that could be resetting it for me?

Thanks for you time.
Loren

Re: Page model returning null

by jthomerson :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, Nov 2, 2009 at 4:57 PM, Loren Cole <loren.cole@...> wrote:

>                HomePage hp = (HomePage) this.findPage();
>                ModelEntity account = (ModelEntity)
> parent.getInnermostModel();
>

Is this just a typo?  You're getting the home page and then getting the
innermost model from something else?

Shouldn't it be hp.getModel()?

--
Jeremy Thomerson
http://www.wickettraining.com

Re: Page model returning null

by Loren Cole :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Oh.  That is embarrassing.  Sorry for taking your time.

On Mon, Nov 2, 2009 at 7:47 PM, Jeremy Thomerson
<jeremy@...>wrote:

> On Mon, Nov 2, 2009 at 4:57 PM, Loren Cole <loren.cole@...> wrote:
>
> >                HomePage hp = (HomePage) this.findPage();
> >                ModelEntity account = (ModelEntity)
> > parent.getInnermostModel();
> >
>
> Is this just a typo?  You're getting the home page and then getting the
> innermost model from something else?
>
> Shouldn't it be hp.getModel()?
>
> --
> Jeremy Thomerson
> http://www.wickettraining.com
>