Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot access inner class in bean

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?

like image 638
user579674 Avatar asked Apr 03 '12 16:04

user579674


1 Answers

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}.

like image 76
BalusC Avatar answered Jan 04 '23 01:01

BalusC