Search code examples
jsfprimefacesjsf-2convertersselectonemenu

How I can use a converter in a JSF tag selectOneMenu?


The following example works in my interface:

<h:outputText value="#{diplome.pays}">
    <gn:converter origine="#{config.origManSirhen}"
                  nomenclature="#{config.codePays}"
                  propriete="libelleImpression" />
</h:outputText>

However, when I try to use the same converter does not work when the element is a selectOneMenu

<p:selectOneMenu id="pays">
    <f:selectItem
        itemValue="#{InformationsPersonnellesModele.adressePrincipale.pays}"
        itemLabel="#{InformationsPersonnellesModele.adressePrincipale.pays}" />
    <gn:converter origine="#{config.origManSirhen}"
        nomenclature="#{config.codePays}" propriete="libelleImpression" />
</p:selectOneMenu>

I have tried to use the attribute converter into the selectOneMenu tag, but it does not work as I expect because I need to use as well the parameter nomenclature and propiete.


Solution

  • I found a possible solution:

    The item selected by default must be the value of the selectOneMenu tag.

    And the list of items and the converter are directly assigned to the value of the selectItems tag.

    <p:selectOneMenu id="pays"
        value="#{InformationsPersonnellesModele.adressePrincipale.pays}">
        <f:selectItems
            value="#{gnl:listeTri(config.origManSirhen, config.codePays,'libelleImpression')}" />
    </p:selectOneMenu>