Accessing parameter of container from mixin

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

Accessing parameter of container from mixin

by Alfie Kirkpatrick :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi, I am writing a mixin that can be used with submit, actionlink,
linksubmit and other things that support a zone parameter.

 

I need to know the zone name from the container. I can add a zone
parameter to my mixin but it's 'namespaced', ie. doesn't pick up the
zone parameter of the container.

 

I would like to write a defaultZone method but cannot see an obvious way
to get the parameter from the container. I am injecting the container
fine but the zone field is private with annotation rather than exposed
with a getter.

 

The workaround is to duplicate the attribute, eg:

 

                <t:actionlink t:mixins="overlay" zone="x"
overlay.zone="x">...</t:actionlink>

 

This works fine but is not quite as elegant as I'd like!

 

Any ideas?

Thanks, Alfie.


Re: Accessing parameter of container from mixin

by kristian.marinkovic :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

there is no way to do so right now. see
https://issues.apache.org/jira/browse/TAP5-103 

there has been some comments on this matter recently (see
http://tapestry-dev.markmail.org/search/?q=TAP5-103)

g,
kris




"Alfie Kirkpatrick" <Alfie.Kirkpatrick@...>
02.07.2009 10:08
Bitte antworten an
"Tapestry users" <users@...>


An
"Tapestry users" <users@...>
Kopie

Thema
Accessing parameter of container from mixin






Hi, I am writing a mixin that can be used with submit, actionlink,
linksubmit and other things that support a zone parameter.

 

I need to know the zone name from the container. I can add a zone
parameter to my mixin but it's 'namespaced', ie. doesn't pick up the
zone parameter of the container.

 

I would like to write a defaultZone method but cannot see an obvious way
to get the parameter from the container. I am injecting the container
fine but the zone field is private with annotation rather than exposed
with a getter.

 

The workaround is to duplicate the attribute, eg:

 

                <t:actionlink t:mixins="overlay" zone="x"
overlay.zone="x">...</t:actionlink>

 

This works fine but is not quite as elegant as I'd like!

 

Any ideas?

Thanks, Alfie.



Re: Accessing parameter of container from mixin

by DH-14 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

One way is using the internal API, which is not recommended. I don't know whether there is a better one.

@Inject
 private ComponentResources componentResources;

public String getZone() {
   InternalComponentResourcesImpl containerResources = (InternalComponentResourcesImpl)componentResources.getContainerResources();
   String zone= (String)containerResources.getBinding("zone").get();
   return zone;
}


DH
http://www.gaonline.com.cn

----- Original Message -----
From: "Alfie Kirkpatrick"
To: "Tapestry users" <users@...>
Sent: Thursday, July 02, 2009 4:08 PM
Subject: Accessing parameter of container from mixin


Hi, I am writing a mixin that can be used with submit, actionlink,
linksubmit and other things that support a zone parameter.

 

I need to know the zone name from the container. I can add a zone
parameter to my mixin but it's 'namespaced', ie. doesn't pick up the
zone parameter of the container.

 

I would like to write a defaultZone method but cannot see an obvious way
to get the parameter from the container. I am injecting the container
fine but the zone field is private with annotation rather than exposed
with a getter.

 

The workaround is to duplicate the attribute, eg:

 

                <t:actionlink t:mixins="overlay" zone="x"
overlay.zone="x">...</t:actionlink>

 

This works fine but is not quite as elegant as I'd like!

 

Any ideas?

Thanks, Alfie.