This should be easy to do, you have several options... you can define a unique 
id for the component, you can define a counter in a base page, you can use an 
annotation that you check for, you could use @InjectContainer which is probably 
the easiest option and simply read a property from the parent... its all 
depends what you want to do, to get a more precise solution you need to show 
your code!

If you find none of these options suits your needs then you could extend 
Tapestry with something custom, like your own injection provider.

Cheers,
Peter

----- Original Message -----
From: "Alessio Gambi" <[email protected]>
To: "Tapestry users" <[email protected]>
Sent: Thursday, 16 September, 2010 01:24:53 GMT +02:00 Athens, Beirut, 
Bucharest, Istanbul
Subject: Enforcing constraints on component instances in pages

Hi,

I'm trying to find an elegant way in T5.1 to ensure that a page contains one 
and only once instance of a given component.

My initial idea was to define a base page class that has the logic to render 
the component using the Component annotation, and to check for duplicates of 
the same component (to remove them or to generate an exception). Unfortunately, 
I was no able to get it working properly, I get either an exception during the 
rendering phase or the template of that component is not rendered at all.

I though about using an approach similar to the layout component as a 
workaround, thus avoiding the inheritance among pages, but I prefer to use thus 
approach as B-plan.

Do you have any suggestion ?

Thanks

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


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

Reply via email to