0

Below is the code from my front end.

  <f:selectItems value="#{bean.choices1.entrySet()}" var="entry"
    itemValue="#{entry.key}" itemLabel="#{entry.value}" />

Where in my back end I have values set for choice1 which is of type Map like.

 Map<String, Long> choices1= new HashMap<String, Long>();

But I am getting an error

Error Parsing: #{bean.Choices1.entrySet()}

I saw lot of examples but most of them are doing what I am using. Please correct if I am doing anything wrong.

I am using,

  • jsf-api-2.1.6.jar
  • jsf-impl-2.1.6.jar
Tiny
  • 27,221
  • 105
  • 339
  • 599
tom
  • 5,114
  • 6
  • 24
  • 36
  • is it normal that in your JSF you use Choices1 and in your bean choice1 ? – Yassin Hajaj Oct 14 '15 at 20:42
  • Sorry it is an Typo, I have both lowercase c – tom Oct 14 '15 at 20:43
  • try to add the metod public Map getChoices1() and use lcase in f:selectItems – Petter Friberg Oct 14 '15 at 20:43
  • I have an getter method already set. – tom Oct 14 '15 at 20:44
  • Try to just pass the Map remove entrySet(), not sure but doc says it evaluats Map – Petter Friberg Oct 14 '15 at 20:47
  • However doc also states that itemLabel needs to be String you are passing Long... booh – Petter Friberg Oct 14 '15 at 20:49
  • The key and value pair is inferred as the option label and the option value respectively in the generated HTML ``. Just do ``. – Tiny Oct 14 '15 at 20:49
  • You will need to interchange key/value in the existing `Map`. [Already answered](http://stackoverflow.com/a/11489020/1391249). – Tiny Oct 14 '15 at 20:58
  • I changed Map then removed entry set but now i am gettign an error Property 'key' not found on type java.lang.String – tom Oct 14 '15 at 21:02
  • Remove those all attributes, `var` , `itemValue` and `itemLabel` from ``. They are not required. (Click the linked answer). – Tiny Oct 14 '15 at 21:07
  • Direct method calls with parentheses syntax as in `#{map.entrySet()}` is only supported since EL 2.2. Problem suggests that your EL implementation is outdated. To confirm this, we need to know exact server make/version, web.xml version, and all JARs in /WEB-INF/lib. If confirmed, then this Q&A is a duplicate: http://stackoverflow.com/q/3284236 – BalusC Oct 14 '15 at 21:10

0 Answers0