This is what the Environment service, and the @Environmental annotation, is for.

An outer component can store an object into the service, and nested
components can pull the object back out (using the object type,
typically an interface, as the key).

For example, BeanEditForm stores an environmental value that
identifies the type of property being editted, along with methods to
read and set the property value (and a couple of other things).
Components that render inside the BeanEditForm (even those that are
dragged in from other pages), have access to that object.

Parametes are merely the most common and convienient way for different
objects (including components) to share information, but far from the
only one.

On 6/22/07, Doug Hauge <[EMAIL PROTECTED]> wrote:
Is there a way to pass a parameter from an outer component to a deeply
nested inner component without having to explicitly pass the parameter
to all intervening components? Basically, we have a parameter, 'node',
whose value is calculated at the page level when handling the 'activate'
event from the activation parameters. Suppose we have components 'A',
'B', 'C', 'D', where the page references 'A', 'A' references 'B', 'B'
references 'C', and 'C' references 'D'. Component 'D' needs the value of
'node', but 'A', 'B', and 'C' don't, so we would like to avoid having to
declare the 'node' parameter in those intervening components and passing
the value in explicitly. I can't seem to find a way to do this. I have
considered

1) Creating a service for calculating the code, but the calculation
requires page parameters, and I can't think of a way to access to these
from a service builder method (outside of nasty hacks like setting the
value in a thread local variable).

2) Creating a new parameter binding factory that traverses up component
containers until it finds one that has the named binding. However,
'ComponentResources' can get a binding type and see if a parameter is
bound, but it does not provide access to the parameter binding itself.
'InternalComponentResources' provides read and write access to the
parameter, but we aren't supposed to use internal services.

Am I missing something?

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




--
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

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

Reply via email to