jsr372-experts@javaserverfaces-spec-public.java.net

[jsr372-experts] 1078-DataModelRegistrable

From: arjan tijms <arjan.tijms_at_gmail.com>
Date: Sun, 8 Mar 2015 23:22:56 +0100

Hi,

As the third part of extending the data model wrappers for UIData and
UIRepeat, it was suggested to make data model wrappers registrable by
the user. Issue JAVASERVERFACES_SPEC_PUBLIC-1078 was created for this,
but it was also mentioned as part of JAVASERVERFACES_SPEC_PUBLIC-1103.

I took a quick look, and now with CDI available it seems almost
trivial to implement this.

JSF would provide a CDI qualifier annotation like:

@Retention(RUNTIME)
@Target(TYPE)
@Inherited
@Qualifier
public @interface FacesDataModel {
    Class<?> forClass();
}

The user then provides something like the following:

@FacesDataModel(forClass=MyObject.class)
public class MyDataModel<E> extends DataModel<E> {
    // datamodel methods
}

The runtime then looks up an instance of that via CDI (just like
happens now for CD Converters and Validators, which is almost a
one-liner in Manfred's CDIUtils).

Thoughts?

Kind regards,
Arjan Tijms