Hi again,

That's a typo.  The Layout class name should read 'Layout' and not
'InnerLayout' but the relevant code is the same.

Ah, okay.

A potential solution would be to use ComponentResources#getPage to get your page in a getter and just use that in your layout.

Unfortunately, that won't work.  CompontResources#getPage returns
(org.apache.tapestry5.runtime.)Component, which doesn't expose the page's
properties. (See Howard's post at:
http://www.nabble.com/Re%3A--T5--Expansions---calling-page-methods-via-componentResources-p19006392.html)

It works if you cast it:

  @Inject
  private ComponentResources resources;

  public BasePage getPage() {
    return (BasePage) resources.getPage();
  }

It just doesn't work directly with property expressions like ${resources.page}.

I'm a bit confused by the terminology. I can't seem to find the docs on
@InjectContainer, but I assumed it injected the 'parent' of the component,
because the page is the root of the component tree.  Now now it seems that
it injects the contents of the layout?

@InjectContainer does indeed inject the "parent" of the component. For InnerLayout this is the page alright, but for Layout it's actually the InnerLayout because Layout is contained in InnerLayout.

The exception states this as well, this is what I missed the first time through:

"Component TestPage:innerlayout is not assignable to field
test.components.Layout.page (of type test.BasePage)."

So the component innerlayout in the page TestPage is not assignable to the field page in Layout - because Layout expects page to be of type BasePage.

There must be a way to do this...

See above. Just use ComponentResources and cast it, simple as that.

Richard

-Filip

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to