I use a JSF 2.2, a Primefaces 6.0 and a CDI. I've got a datatable which has implemented lazy loading (the datatable downloads the data from the database). Each column has got a filter field.
One of the column has to have readonly filter field (I save a value for this filter in some variable before displaying the datatable). So, as I wrote, this filter field should be readonly (non-editable) and the filter should take the value from this field into filtering. How can I achieve this feature?
I tried to add the inputtext component and set the readonly attribute:
<p:dataTable id="dataTableOfDataStore" var="obj" widgetVar="dataTableOfDataStoreVar"
value="#{formVisualizationController.dataTableLazy}"
lazy="true"
filteredValue="#{formVisualizationController.filteredDataTable}"
filterDelay="2000"
<!-- other attributes -->
>
<!-- other columns -->
<p:column headerText="Source IP" sortBy="#{obj.sip}"
filterBy="#{obj.sip}" filterMatchMode="contains">
<f:facet name="filter">
<p:inputText readonly="true" onchange="PF('dataTableOfDataStoreVar').filter()"
value="#{formVisualizationController.selectedSourceIPFieldOfFiltr.ip}"
style="width: 100%; background-color: #0088cc; color: #ffffff;"/>
</f:facet>
<h:outputText value="#{obj.sip}" />
</p:column>
<!-- other columns -->
</p:dataTable>
Unfortunately it doesn't work. When I delete the readonly attribute, it works, but then the filter field is editable as well.
Of course, I can achieve this by manually pass on this value to the database query and then delete the filter from the column and keep the inputtext component with the value (and with readonly attribute), but maybe you know some different way to achieve this.