2 Replies Latest reply on May 15, 2009 6:47 PM by Dan Allen

    How do I create an alias for a bean name?

    Dan Allen Master

      Obviously, bean names must be globally unique in an application. Otherwise, the result of looking up a bean by name (such as in the EL) would be ambiguous. Thus, it's best practice to provide fully qualified names for beans. The Web Beans RI follows this practice when naming the Conversation bean:

      class ConversationImpl implements Conversation, Serializable

      However, it would be pretty annoying to always have to type #{javax.context.conversation} in your view templates. Therefore, applications will want to alias this name to a shorter name that the developer can guarantee will not clash with other names in the application. The question becomes, how is this done? Is it as easy as defining a name for Conversation in beans.xml? In that case, would it be the interface or the implementation? And does the name provided in XML override the name in the annotation?

      Btw, we need to use this pattern a lot in Seam 3, so it's important to nail it down now.