You can handle it with ajax in jsf 1.2 also with p:ajax provided by primefaces.
First of all remove onChange="document.datsForm.submit()"
from h:selectOneMenu
and add
as child component of your select menu.
<p:ajax event="change" process="@this" partialSubit="true" update="datatable"
listener="#transactionListAction.onYearChange}"/>
You haven't given any id to the form contaning datatable which is not a good practice. Give id to the form and refer datatable as :formId:datatable
. Above update="datatable"
only works in case if your dropdown and datatable are inside the same form.
Declare method in your action class like
public void onYearChange() {
transActionsList = transactionService.getByYearId(yearId);
}
declare a variable List<Transaction> transActionsList
in your class and bind it to the value of the datatable. You should not perform any action in getter method because jsf framework calls getters and setters multiple times which results in multiple hits to the db.
Hope this helps.