16

I'm using JSF 2.0. I have a managed bean which I can access through my xhtml page. Inside the bean I declared an inner class. I can access ArrayList<String> of managed bean but not ArrayList<InnerClass> and I get the error that the InnerClass does not have a readable property. Anyone know what's wrong?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
user579674
  • 2,159
  • 6
  • 30
  • 40

1 Answers1

33

That can happen if the inner class is not public. It will then be invisible to other classes outside the package (like as JSF/EL itself!). Make sure that the inner class is public whenever you need to access it by JSF/EL.

public class Bean {

    public class InnerClass {
        // ...
    }

}

Otherwise it will be interpreted as String and you'll get confusing exceptions like

javax.el.ELException: /test.xhtml: Property 'someProperty' not readable on type java.lang.String

when you want to access #{innerClass.someProperty}.

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • 1
    I found this after 2 hours of looking for a bug. I guess they should at least make the exception more clear. The String here refers to the expected type(in my case it was boolean), which is really confusing. – NeplatnyUdaj Sep 18 '13 at 16:21