How to create a list with Months to change the Datatable result?

Asked

Viewed 89 times

-1

I have a dataTable that brings the data of a specific month set in DAO.

I would like to create a field where I select the month and it updates the table with the selected month.

You have to use ajax?

  • Post what you’ve done so far for better understanding.

1 answer

0

To select a month of a year, use the component Calendar. You’ll have to ignore the day, but it works.

If you look at documentation will see that there is an attribute called update which can be used to update another component when a date is selected and the event dateSelect occur.

Example based documentation:

<p:calendar value="#{calendarBean.date}">
    <p:ajax event=”dateSelect” listener=”#{bean.handleDateSelect}” update=”<id da tabela ser atualizada>” />
</p:calendar>

The method handleDateSelect() can perform some necessary logic, but the important thing is that the method that generates the values of the dataTable read the value of calendarBean.date and extract the month and year to update the table.

Browser other questions tagged

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