Update datatable when searching for autocomplete

Asked

Viewed 97 times

0

Good morning, everyone. Could someone ask a question? Good is the following, I have a component of the first faces autocomplete and a datatable, but when I perform a search for the autocomplete, it does not update my datatable, how do I do this?

Below follows my autocomplete and my datatable:

<p:autoComplete id="station_select"
   value="#{pmvBean.pmv}"
   completeMethod="#{pmvBean.completePmv}"
   var="pmv" itemValue="#{pmv}"
   itemLabel="#{pmv.location}"
   converter="pmvConverter"
   styleClass="autoComplete-1"
   placeholder="#{bundle['system.msg.history.selectPmv']}" 
   dropdown="true" 
   scrollHeight="500">

</p:autoComplete>

<p:dataTable id="pmv_datatable" value="#{pmvBean.listPmv}"
    widgetVar="pmvDatatable" var="pmv" rowKey="#{pmv.id}"
    sortBy="#{pmv.location}"
    emptyMessage="#{bundle['system.ui.label.emptyDataTable']}"
    style="margin-top: 10px;">

1 answer

0

You need to use an ajax to update the datatable and create a method in your Bean to handle the event:

<p:autoComplete ...atributos...>
  <f:ajax event="itemSelect" 
    listener="#{pmvBean.listenerParaEsseEvento}" render="pmv_dataTable" />
</p:autoComplete>

Browser other questions tagged

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