In my class i have a function according to:
public List<String> getDeclaredFields() {
List<String> fieldList = new ArrayList<String>();
for(Field field : Equipment.class.getDeclaredFields()){
if(!field.getName().contains("_") && !field.getName().equals("id") && !field.getName().equals("serialVersionUID") ) {
fieldList.add(field.getName());
}
}
Collections.sort(fieldList);
return fieldList;
}
which returns a list of strings of all declared fields in the class.
In my facelet file I would like to perform something like:
<c:forEach var="field" items="#{bean.entity.declaredFields}">
<h:outputText value="#{msg.#{field}}" />
</c:forEach>
However, this will result in errors.
javax.el.ELException: Error Parsing: #{msg.#{field}}
I would like to do this, cause when I do some changes of field(s) in my class, I simply add a variable in my message bundle with the same name as a field. At this way, I dont have to update all my facelet files when modifying fields. Just remove or add new variables in the message bundle file.
Do you have some ideas?
Best regards
you should be able to reference it using [] notation:
give that a try