Em Wed, 04 Mar 2009 21:47:31 -0300, Luther Baker <lutherba...@gmail.com> escreveu:

Can I safely @Inject this encoder into multiple/different pages?
class MoviePage
{
    @Inject
    private ValueEncoder<Movie> encoder;

Java does not let you do that because of the way it implemented generics. Anyway, Select (and maybe some other components) use ValueEncoderSource to get a ValueEncoder for a given type. Take a look at TapestryModule.contributeValueEncoderSource().

If this is safe, although I only bound one instance, does it create a new
instance of the service for each Generic<Parameter> type?

It wouldn't work like you want.

What should happen with something like this:
        binder.bind(AbstractSelectModel.class, GenericSelectModel.class);
when there is no "left-hand" Generic to infer the Generic Parameter from:
class VideoPage
{
    @Inject
    private AbstractSelectModel model;

I guess this would work. But I suggest you to use binder.bind(GenericSelectModel.class) (without the "left-hand") and then @Inject it like any other service.

This is a purely Tapestry-IoC thing, not exactly a Tapestry-Core (web framework) issue. You can read more about injection and services at http://tapestry.apache.org/tapestry5/tapestry-ioc/service.html. I'm just parroting what's written there. :)

--
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to