jsf - Filter does not take a value from readonly field during filtering -
i use jsf 2.2, primefaces 6.0 , cdi. i've got datatable
has implemented lazy loading (the datatable
downloads data database). each column has got filter field.
one of column has have readonly
filter field (i save value filter in variable before displaying datatable
). so, wrote, filter field should readonly
(non-editable) , filter should take value field filtering. how can achieve feature?
i tried add inputtext
component , set 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 doesn't work. when delete readonly
attribute, works, filter field editable well.
of course, can achieve manually pass on value database query , delete filter column , keep inputtext
component value (and readonly
attribute), maybe know different way achieve this.
this answer explains why readonly fields not included in request. therefore primefaces not use filter.
in opinion have override/check anyways on serverside if want ensure has not been tampered with. therefore setting programatically seems best solution.
you can either in query or adding filter value programatically. example override load method use value bean if mandatory.
datatablelazy = new lazydatamodel<?>(){ public list<site> load(int first, int pagesize, string sortfield, sortorder sortorder, map<string, string> filters) { //set filter here super.load(first, pagesize, sortfield, sortorder, filters); } }
Comments
Post a Comment