Is it possible to dynamically access properties using #evaluate? I apologize in advance for the length, but most of this is just sample code to fully illustrate my problem.
I have a preference class that looks like this:
public class DefaultUserPreferences implements Preferences {
Each of these types is just a custom enumeration.
public enum OrderByColumn { NAME, LAST_ACTIVITY, GROUP } public enum Panel { MOST_ACTIVE, RECENTLY_MODIFIED; public String getCamelCase() { String[] words = StringUtils.split(this.name(), "_"); String rval = StringUtils.EMPTY; if (words != null && words.length >= 1) { rval = StringUtils.lowerCase(words[0]); for(int i = 1; I < words.length; i++) { rval += StringUtils.capitalize(words[i].toLowerCase()); } } return rval; } }
Below is a snippet of how Id like to display preferences for users, but I can't get him to get a call (I get the following if I rate it to get the text: test.core.model.entities.DefaultUserPreferences @ 596fde80.mostActiveSortOrder)
#for ($panel in $Panels) ## The names here are correct #set($selectName = ${panel.CamelCase}SortColumn) #set($dynamicProperty = $preferences.$selectName) <tr> <td>$panel</td> <td> <select name="$selectName"> #for($option in $OrderByColumn) <option value="$option" #if($option == #evaluate($dynamicProperty) selected="selected" #end>$option</option> #end </td> </tr> #end
However, my getter never seems to have triggered a preference. I added each of the parts to the context, and I have no problems with the panels, I just can’t get the syntax to dynamically call getters properties. Is this possible in 1.7?
Scott source share