I have currently the following code:
<h:form id="activitiesListForm" rendered="#{activitiesRequestByObjectController.init('BOOKING_DATE', bookingDateEditController.bookingDate.id)}">
<p:dataTable id="activitiesListDatatable" value="#{activitiesRequestByObjectController.lazyModel}" var="activities" rows="50">
<p:column sortBy="#{activities.activityActionType}"
visible="true">
<f:facet name="header">
<h:outputText value="Aktion" />
</f:facet>
</p:column>
</p:datatable>
</h:form>
In my backend bean I have the following code:
public boolean init(String activityType, Long id) {
LOGGER.info("START init");
LOGGER.info("activityType: " + activityType);
LOGGER.info("id: " + id);
// loadContent from database
This code works and I got the result what I would like to have, but if I have a look in the log, I see that the function in the backend is called many times which is bad. I can generate many backend classes to load the content, e.g. for BOOKING_DATE, CUSTOMER etc. - but I want to avoid this, because otherwise I will have around 100 classes with moreless the same content, only with other parameters.
My question is, is there any possibility to have only one class to load the content from: activitiesRequestByObjectController.lazyModel
but with different parameters or avoid that the backend bean is loaded many times. The best would be if I can have still the function: #{activitiesRequestByObjectController.init('BOOKING_DATE', bookingDateEditController.bookingDate.id)} , loading only one time and get the result.
Any ideas?