Show itemLabel instead of ivemValue in Datatable - JSF, Primefaces

Asked

Viewed 35 times

0

Well, I am working on a project and when saving a register using selectOneMenu of the primefaces, an Id is being displayed instead of the field name that was selected, I need to know how to display only the field name.

Here is my xhtml:

<p:outputLabel for="tipoTratamentoCB" value="Tipo de tratamento:" />
                <p:selectOneMenu id="tipoTratamentoCB"
                    value="#{guiaEncaminhamentoBean.guiaEncaminhamento.tipoTratamentoCB}"
                    style="width:185px">
                    <f:selectItem itemLabel="Hospitalização Diurna - HD" itemValue="0" />
                    <f:selectItem itemLabel="Hospitalização Noturna - HN" itemValue="1" />
                </p:selectOneMenu>

My variable typeTreatmentCB is declared so in my class:

private String tipoTratamentoCB;

The problem is that I display in my xhtml the value that is saved in ivemValue in selectItem, need to know how to display the value of itemLabel, someone has idea of how to do this?

1 answer

0

If I understand correctly, you want to save the value of the itemLabel in typeTreatmentCB. If so, try to change the following:

<f:selectItem itemLabel="Hospitalização Diurna - HD" itemValue="Hospitalização Diurna - HD" />
<f:selectItem itemLabel="Hospitalização Noturna - HN" itemValue="Hospitalização Diurna - HD" />

Browser other questions tagged

You are not signed in. Login or sign up in order to post.