I’m encountering some troubles while trying to access some properties with parameters. Well, I don’t know if they should be called properties since the accessors have parameters but lets call them properties for now.
The situation is this:
I have a Student class that contains different localizations as objects in a map. I can get those localization objects by doing this:
student.getLocalizedData(String localizationCode);
Now, on the page, I’m trying to do this:
<h:inputText value="#{collegeBean.student.getLocalizedData('es').profileDescription}"/>
A student’s description can have many localizations.
The page loads correctly, but when I try to save the student it says that the bean collegeBean does not have the property getLocalizedData, tough that one is a property of the student contained on the bean.
I know that line is insane, so I tried to wrap it:
<h:inputText value="#{collegeBean.getStudentLocalizedData('es').profileDescription}"/>
Alas, again I get the same message.
The only solution I’ve found is to make a method that completely wraps the studen’t sproperty… but that leaves me with 2 methods (get + set) for every localization, and that’s only for one property. This means that I’ll end having (2 x localizations x attributes) amount of methods!.
Is there any approach I can take to solve this in the most dynamic way? The ammount of localizations might change in the future and I don’t want to change any code.
EDIT: I’m using JBoss 6.1.0.Final and the JSF implementation that comes with it JSF 2.0.3-b05
This should theoretically work, so I suspect a bug or an oversight in the EL implementation used. You might want to try a different EL implementation (a different server make) or to upgrade the server. If in vain, report it as a bug to the server vendor.
However, since you’re actually delegating the
getLocalizedData()to aMap, better is to not do that but instead return the wholeMapdirectly.so that you can use it as follows
or, if desired