marți, 13 octombrie 2015

JSF 2.0-2.3 Progress of Iterable/Map support in UIData/UIRepeat (OmniFaces support via utility functions)

Related to this topic must read:

Iterating in UIData (e.g. <h:dataTable>)
JSF 2.0/2.1
- supports the List, native array and JSF specific DataModel as input for its value binding
- for Iterable (e.g. Queue, Set) you can use the OmniFaces function, of:iterableToList().
- for Set only (especially useful to Hibernate/JPA users, who are usually using the Set collections for entity relationships)
  you can use the OmniFaces function, of:setToList().
- if EL 2.2 is available, for Iterable, you can use toArray() (e.g. #{fooBean.fooIterable.toArray()}).
- for Map you can use the OmniFaces function, of:mapToList().
- if EL 2.2 is available, for Map, you can use toArray() (e.g. #{fooBean.fooMap.entrySet().toArray()} or #{fooBean.fooMap.keySet().toArray()}
  or #{fooBean.fooMap.values().toArray()}).

JSF 2.2                                                                                          
- supports the List, native array and JSF specific DataModel as input for its value binding
- you can use directly the Iterable (e.g. Set, Queue)
- for Map you can use the OmniFaces function, of:mapToList().
- since Iterable is directly supported, you can use  it as #{fooBean.fooMap.entrySet()} or #{fooBean.fooMap.keySet()}or #{fooBean.fooMap.values()}

JSF 2.3                                                                                          
- supports the List, native array and JSF specific DataModel as input for its value binding
- you can use directly the Iterable (e.g. Set, Queue)
- you can use Map directly

<h:dataTable value="#{fooBean.fooMap}" var="t">
 #{t.key} #{t.value}
</h:dataTable>

You can see a complete demo here (it was tested with Mojarra 2.3.0 Milestone 4 under Payara 4.1.

Iterating in UIRepeat (e.g. <ui:repeat>)
JSF 2.0/2.1/2.2
- supports the List, native array and JSF specific DataModel as input for its value binding
- for Iterable (e.g. Queue, Set) you can use the OmniFaces function, of:iterableToList().
- for Set only (especially useful to Hibernate/JPA users, who are usually using the Set collections for entity relationships)
  you can use the OmniFaces function, of:setToList().
- if EL 2.2 is available, for Iterable, you can use toArray() (e.g. #{fooBean.fooIterable.toArray()}).
- for Map you can use the OmniFaces function, of:mapToList().
- if EL 2.2 is available, for Map, you can use toArray() (e.g. #{fooBean.fooMap.entrySet().toArray()} or #{fooBean.fooMap.keySet().toArray()}
  or #{fooBean.fooMap.values().toArray()}).

JSF 2.3                                                                                          
- supports the List, native array and JSF specific DataModel as input for its value binding
- you can use directly the Iterable (e.g. Set, Queue)

<ui:repeat value="#{fooBean.fooSet}" var="t">
 ...
</ui:repeat>

- you can use Map directly

<ui:repeat value="#{fooBean.fooMap}" var="t">
 #{t.key} #{t.value}
</ui:repeat>

You can see a complete demo here (it was tested with Mojarra 2.3.0 Milestone 4 under Payara 4.1.

Niciun comentariu:

Trimiteți un comentariu