users@glassfish.java.net

CDI + EL question

From: Petr Jiricka <Petr.Jiricka_at_Sun.COM>
Date: Tue, 19 Jan 2010 21:19:08 +0100

Hi,

the following example does not work for me, and I would appreciate
help with making it work.

I have the following interface:

@Named
@RequestScoped
public interface Bean extends Serializable {
     public String getName();
}

with the following implementation:

public class BeanImpl implements Bean, Serializable {
     public String getName() { return "x"; }
}

Now, I would expect that I can write #{bean.name} in JSF, and CDI will
find the BeanImpl class and use it. However, in reality 'bean' is not
found (although the server log does not contain any error messages
that would help me track this down). Is this supposed to work?

When I use the following in Java code:
public @Inject Bean mybean;

everything works fine. Also, when I delete BeanImpl and change Bean to
a class, then #{bean.name} works correctly.

Thanks,
Petr