Question

I am trying to get the first value of a map by following

TreeMap<String, String> myMap = new TreeMap<String, String>();
myMap.put("key1","value1");
myMap.put("key2","value2");
String first = myMap.firstEntry().getValue();
String firstOther = myMap.get(myMap.firstKey());

its working for me writing in Java

In same i am using expression in jsf like following

${criterion.variableBindings.firstEntry.getValue()} 

In this scenario I didn't get the value.

Was it helpful?

Solution

Please # for the calling method or variable of a bean class..

#{criterion.variableBindings.firstEntry.getValue()}

If you didn't get for for above

create a variable inside bean class setter and getter then access that variable in jsf file.

In bean

 private String  first ;  
 first = myMap.firstEntry().getValue();
 //setterand getter

in jsp

#{bean.first}

OTHER TIPS

You're trying to invoke the method firstEntry, so you need to use method invocation syntax, which has parentheses after the method name:

${criterion.variableBindings.firstEntry().getValue()} 

If the method had been named getFirstEntry you could have accessed it as a property as well, but since it does not start with get you need to access it as a method.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top