JSF & EL Specification (Resend)

From: Freire, Jose Luis \(PT - Lisbon\) <"Freire,>
Date: Thu, 5 Nov 2009 10:14:46 +0000

If you remember, 5 months ago I stumbled on a EL limitation on managed beans with generic types (thread with subject "Is JSF incompatible with generics?").

To refresh your memory, the problem is when we have a class like:

public class GenericsTestController<E extends Object> {

       private E value;

       public E getValue() {

              return value;


       public void setValue(E value) {

              this.value = value;



And we have this class to use as a managed bean (integerTest):

public class IntegerTestController extends GenericsTestController<Integer> {

       public String add() {


              return null;


       public String subtract() {


              return null;



This JSF code will not work:



       <h:inputText value="#{integerTest.value}" />

       <h:commandButton action="#{integerTest.add}" value="+" />

       <h:commandButton action="#{integerTest.subtract}" value="-" />


With this error:

java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Integer

       at genericstest.IntegerTestController.add(

I've tried to get in touch with the EL Spec leader (Kin-man Chung) as suggested, but I've got no reply. I've sent a mail to the (empty) UEL mailing list, and I've got no reply.

I've got my own version of EL (based on jboss-el) working even with very complex generic inheritance. However, the changes are in code covered by the spec, more specifically, with section 2.2.7 of the specification:

The provided property will first be coerced to a String. If there is a BeanInfoProperty for this

property and there were no errors retrieving it, the propertyType of the propertyDescriptor is

returned. Otherwise, a PropertyNotFoundException is thrown.

The propertyType of a generic property is Object.class, that gets coerced to String.class, and we get the ClassCastException.

So, what should we do? I'm I the only one that is using generics and JSF?


José Freire
Consulting - Financial Services Industry
Deloitte Consultores, S.A.
Deloitte | Edifício Atrium Saldanha, Praça Duque de Saldanha, 1 - 7º, 1050-094 Lisboa, Portugal
Tel/Direct: +(351) 210 422 500 | Fax: +(351) 210 422 950 |

Please consider the environment before printing.

Deloitte refers to one or more of Deloitte Touche Tohmatsu, a Swiss Verein, its member firms, and their respective subsidiaries and affiliates. As a Swiss Verein (association), neither Deloitte Touche Tohmatsu nor any of its member firms has any liability for each other's acts or omissions. Each of the member firms is a separate and independent legal entity operating under the names "Deloitte," "Deloitte & Touche," "Deloitte Touche Tohmatsu," or other related names. Services are provided by the member firms or their subsidiaries or affiliates and not by the Deloitte Touche Tohmatsu Verein.
Privileged/Confidential Information may be contained in this message. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person), you may not copy or deliver this message to anyone. In such case, you should destroy this message and kindly notify the sender by reply email. Please advise immediately if you or your employer do not consent to Internet email for messages of this kind. Opinions, conclusions and other information in this message that do not relate to the official business of my firm shall be understood as neither given nor endorsed by it.