[ 
https://issues.apache.org/jira/browse/DELTASPIKE-228?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14392771#comment-14392771
 ] 

Ron Smeral commented on DELTASPIKE-228:
---------------------------------------

A bean annotated just {{@Named @MessageBundle}} doesn't get discovered in the 
"annotated" mode, since neither @Named nor @MessageBundle is bean-defining 
annotation:
http://docs.jboss.org/cdi/spec/1.1/cdi-spec.html#bean_defining_annotations

As per CDI 1.1, 12.4, only beans with bean-defining annotations are discovered 
in archives with "annotated" mode:
http://docs.jboss.org/cdi/spec/1.1/cdi-spec.html#bean_discovery

You could solve it by annotating your message bean e.g. @Dependent, 
@ApplicationScoped, etc.

This _could_ be added to docs, but I'm not sure it makes sense for it to be 
there, since this is governed by the CDI spec. 
Though, as you say, it could be there as a hint, just as in the "Type-safe 
View-Configs" section. Feel free to make a Documentation JIRA and issue a PR 
against github.com/apache/deltaspike.

> Make @MessageBundle annotated type available via EL 
> ----------------------------------------------------
>
>                 Key: DELTASPIKE-228
>                 URL: https://issues.apache.org/jira/browse/DELTASPIKE-228
>             Project: DeltaSpike
>          Issue Type: New Feature
>          Components: I18n-Module, JSF-Module
>    Affects Versions: 0.2-incubating
>            Reporter: Thomas Herzog
>            Assignee: Rafael Benevides
>
> After you defined an MessageBundle type, you wanna use it in the views as 
> well without wrapping the type into a @Named annotated cdi bean to be 
> available to use it via EL.
> It would be fine if the implementation would be created and registrered as an 
> cdi bean at deployment time and therefore available via EL in the views.
> I think the main usage for the messages is in the views, at least in our 
> usacases.
> Therefore it would also nice to define the name of the created cdi bean via 
> maybe @MessageContextConfig annotation and default should be the name of the 
> type, but the name of the type could be same, just placed in different 
> packages.
> If this will be done the developer only has to define his MessageBundle type 
> with the getter for the messages and configuration via annotation if 
> necessary, and use it in the views right away.
> Regarding to issue DELTASPIKE-223 it would be necessary to think about 
> follwing possible issues.
> If there would be multiple choices for the convention of the getter methods 
> for the messages defined in the MessageBundle type, there could occur 
> follwing problems.
> 1. String welcomeTo(); // Key: welcome_to
> 2. String getWelcomeTo();  // Key: welcome_to with get prefix
> 3  String getWelcomeTo();  // Key: get_welcome_to
> @1
> How will EL resolve the method if called via #{type.welcomeTo} ?
> As far as i know EL would try to invoke getWelcomeTo() method which could not 
> be found in this case !!
> @2 and 3
> How will it be distiguished if get prefix is part of the key or just the 
> start of the getter method? 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to