error update label with selectOneMenu java jsf + primfaces

0

Good I am trying to print in label the name when selecting an item in a selectOneMenu but I do not capture it the menu works well shows me all the cedulas available in my tables so my selectOneMenu is defined %:

<p:selectOneMenu value="#{cargarArchivo.ticket.chofer}" style="width: 100%" converter="choferConverter" filter="true" filterMatchMode="contains">
    <f:selectItem itemLabel="" itemValue=""/>
    <f:selectItems value="#{cargarArchivo.listCho}" var="tipo" itemLabel="#{tipo.cedula}" itemValue="#{tipo}"/>                
</p:selectOneMenu>

and this is the label in which I want it to be displayed.

<p:outputLabel value="#{cargarArchivo.ticket.chofer.nombre}" />

    
asked by Alexander Villalobos 30.06.2017 в 17:24
source

1 answer

0

Investigate a bit, from what I could find you could use an ajax event so that when selecting the item within the selectOneMenu your outputLabel changes:

<p:selectOneMenu value="#{cargarArchivo.ticket.chofer}" style="width: 100%" converter="choferConverter" filter="true" filterMatchMode="contains">
    <f:selectItem itemLabel="" itemValue=""/>
    <f:selectItems value="#{cargarArchivo.listCho}" var="tipo" itemLabel="#{tipo.cedula}" itemValue="#{tipo}"/>
    <p:ajax event="change" update="outPut1" />
</p:selectOneMenu>

And to your outputLabel you will assign the update Id in the selectOneMenu:

<p:outputLabel id="outPut1" value="#{cargarArchivo.ticket.chofer.nombre}" />

Even in the ajax, you could use a listener to control it better in the bean, something like this:

...
<p:ajax event="change" update="outPut1" listener="#{cargarArchivo.metodoTickets}"/>
...

I hope your answer will help, greetings.

    
answered by 30.06.2017 / 17:47
source