users@javaserverfaces-spec-public.java.net

[jsr372-experts mirror] [jsr372-experts] Re: Re: Tag to declare and import constants in EL scope

From: Leonardo Uribe <leonardo.uribe_at_irian.at>
Date: Mon, 20 Jun 2016 15:35:16 +0200

Hi

What I can say is there were issues with f:loadBundle and ajax (JSF 1.0).

I would like a simple annotation, so you can just put it on the classes
that contains the constants.

@SomeGoodNameForAConstantClassHolderOrGlobalEnum
public enum Gender{
    ...
}

It is easier to maintain if everything related to the constant is in the
same place. The config option could be also in the faces-config.xml.

regards,

Leonardo




2016-06-20 15:24 GMT+02:00 Bauke Scholtz <balusc_at_gmail.com>:

> Hi,
>
> I didn't know about deprecation of <f:loadBundle>. At least, this is not
> mentioned in VDL:
> https://docs.oracle.com/javaee/7/javaserver-faces-2-2/vdldocs-facelets/f/loadBundle.html
> Where is this issued/discussed?
>
> At least, the intent indeed was that <f:importConstants> should have same
> mechanism as <f:loadBundle>. However, instead of request scope, the values
> can be placed in application (global) scope. At least not in page/template
> scope as that would not work (it would break your ajax example) and also
> not in view scope (technically possible but plain inefficient).
>
> A faces-config.xml based configuration is a reasonable idea. Perhaps even
> better.
>
> Cheers, B
>
>
> On Mon, Jun 20, 2016 at 3:14 PM, Leonardo Uribe <leonardo.uribe_at_irian.at>
> wrote:
>
>> Hi
>>
>> Just as a comment, f:importConstants reminds me f:loadBundle, which was
>> deprecated and replaced by a solution that loads the bundle from the
>> faces-config.xml files.
>>
>> The problem about f:importConstants is how to set up the context where
>> these constants are available. For example
>>
>> <f:importConstants type="com.example.Gender" />
>>
>> <h:selectOneMenu value="#{person.gender}">
>> <f:selectItems value="#{Gender}" />
>>
>> <f:ajax ...../>
>> </h:selectOneMenu>
>>
>>
>> if the ajax is only for the component, f:importConstants can be ignored
>> and the code will break.
>>
>> so, the "challenge" is to find a way to define the EL context properly.
>>
>> In MyFaces there are some EL contexts:
>>
>> - page
>> - template
>> - view
>> - global
>>
>> Sometimes you want a definition to pass through the template, sometimes
>> through the view or sometimes just have a global definition for all your
>> views.
>>
>> regards,
>>
>> Leonardo Uribe
>>
>>
>> 2016-06-20 14:49 GMT+02:00 Bauke Scholtz <balusc_at_gmail.com>:
>>
>>> Hi,
>>>
>>> See https://java.net/jira/browse/JAVASERVERFACES_SPEC_PUBLIC-1424
>>>
>>> This is a commonly requested feature from the community. Several
>>> libraries have it implemented such as OmniFaces and PrimeFaces Extensions.
>>> It would be nice to offer a standard JSF solution such as
>>> <f:importConstants>. It's relatively trivial to implement.
>>>
>>> If there are no objections, I will take it on me.
>>>
>>> Cheers, B
>>>
>>>
>>>
>>
>