Bonjour,

Je sèche littéralement devant un problème qui doit être pourtant simple.

J'ai une classe P_nbVO qui définit un 'value object'.

Lorsque j'instancie un P_nbVO, je peux lire/affecter un nom (String), un code (Long) via getters/setters.

Le but est de rappatrier d'une BDD un ensemble de couple nom/code dans un type définit par moi-même. Donc j'instancie en fait des tableaux de P_nbVO.


A côté de ça, j'ai une méthode (qui n'est pas de moi) que je souhaiterais utiliser.

Le premier argument est une Collection, le second est une 'clé' et le dernier est la valeur correspondant à cette 'clé'.


Problème : je ne vois pas comment une Collection peut contenir une 'clé' d'un côté et sa valeur de l'autre ... et donc je sèche pour convertir mon P_nbVO[] en Collection

Le bout de doc qui suis correspond à la méthode à renseigner.

Merci

void com.delbardpro.production.web.parametres.article.modifier.ChargerFormForm.setAgeBackingList(Collection items, String valueProperty, String labelProperty)
Convenient method to quickly set the value and label backinglist for the age property. This method takes a collection of objects, as well as the property names to query on these objects in order to find the corresponding values and labels.

Let's say you have a set of value objects with the following properties:

id
code
name
description
But you need to populate the age backing list with the id properties as the values and the name properties as the labels then you would make a call like this: setAgeBackingList(valueObjects, "id", "name")
This method knows how to handle primitive property types as it simply delegates to org.apache.commons.beanutils.PropertyUtils.getProperty(Object, String).

See Also:
getAge()
getAgeValueList()
getAgeLabelList()
getAgeLabelList()
Parameters:
items The items from which to read the properties, if this argument is null this method will simply clear the existing values and labels
valueProperty the name of the property to query on each object to retrieve the corresponding value, cannot be null
Throws:
java.lang.IllegalArgumentException if the valueProperty or labelProperty is null
java.lang.RuntimeException if one of the items in the collection is null, or if the caller does not have access one of the object's properties, if an exception was thrown while accessing a property or if the property does not exist on at least one of the items
P.S. L'objectif est de renseigner une listbox