ok, solved. 

maybe this saves someone the trouble when having to do parameter-injections
from abstract-classes etc. 

Instead of trying to push the right component into Baselayout I turned it
upside down and referenced the containing page subclass that knows which
quickform to render, this turned out to be pretty tricky: 

so: 
BaseLayout
-----------------------------
@Parameter(required = true)
private ISuperPage page;

public SuperPage getPage()
{
  return (SuperPage)page;
}

the tricky part was that: 

the templating-engine seems to need (maybe its common knowledge but I didn't
know) a class instead of an interface as output, when referencing ${page}
otherwise all weird errors occur (linkage errors). So getPage() outputs
SuperPage. 

At the same time though I needed subclasses of SuperPage to be injected as
the page property, so they could decide which QuickForm to render. This
would enable me to do: 

BaseLayout.tml
-----------------------
<t:delegate t:id="quickFormDelegate" t:to="page.quickForm"/>

However therefore a coercion is needed between a page subclass and a page
super-class. All good and well, but a coercion between a subclass and
superclass doesn't work under these conditions (see explanation:
http://www.nabble.com/T5%3A-Issues-contributing-a-coercion--tf4715961.html#a13481180)

So I had to create a interface ISuperPage and create a coercion from
SuperPage --> ISuperPage and let SuperPage implement ISuperPage. Now
automatically all subclasses of SuperPage can be coerced to ISuperPage as
well. 

It took some time to figure this one out, but now its working like a charm!
//Geert-Jan



Britske wrote:
> 
> I've got a page-class hierachy which all use component BaseLayout as their
> layout. This BaseLayout-component contains a component called QuickForm. 
> 
> Each page-class must render a QuickForm-component but the implementation
> may differ (so there is more than 1 actual QuickForm-component. 
> 
> I started experimenting with the following: 
> 
> BaseLayout
> -----------------------------
> @Component
> @Parameter(required=true)
> private QuickForm quickForm;
> 
> 
> SuperPage
> ---------------------------
> @Component(parameters = {"page=this","quickform=quickform"})
> private BaseLayout bl;
>       
> @Component
> private QuickForm quickForm;
> 
> So that he actual quickform can be passed as a parameter from (int this
> case) SuperPage to baselayout. 
> However, then component quickForm in class SuperPage must exist in the
> template, which can be done by putting it in a block,  (But SuperPage is
> just what its called, an abstract base-class ,which doens't have a
> termplate, so I must put the block in the templates of all actual
> implementations of SuperPage, etc. ,etc. ) Excuse the ranting, but I think
> you get the point.
> 
> All in all, I don't like this approach at all. Am I missing something
> here? 
> 
> Thanks in advance,
> Geert-Jan 
> 

-- 
View this message in context: 
http://www.nabble.com/T5%3A-how-to-let-subclass-decide-which-component-to-render-tf4820991.html#a13798297
Sent from the Tapestry - User mailing list archive at Nabble.com.


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

Reply via email to