How to use a customized inputmask in primefaces

时间:2019-04-08 13:42:56

标签: regex primefaces maskedinput

I have a datatable displaying a column filled with null values displayed as '-' or numeric data and I want to filter it by allowing the user to enter a dash or a number.

The mask should then allow values as such :

  • -
  • 5
  • 1035487

I've tried using <p:inputMask> as such :

<p:inputMask styleClass="inputMask, filterTextBox" onchange="PF('documentsTable').filter()"
             mask="?-999999999999999999999999999999"
             id="filterDossierNumber" widgetVar="filterDossierNumber"
             value="#{DocumentEncodingTrackingBean.filterDossierNumber}">
    <p:keyFilter regEx="^-?[0-9]+$"/>
</p:inputMask>

Or <h:inputText>

<h:inputText styleClass="inputMask, filterTextBox" onchange="PF('documentsTable').filter()"
             id="filterDossierNumber" widgetVar="filterDossierNumber"
             value="#{DocumentEncodingTrackingBean.filterDossierNumber}">
    <p:keyFilter regEx="/-{0,1}\d{1,}/"/>
</h:inputText>

And i've also tried to use jquery maskedinput plugin like this (imported in the jsf page)

$(document).ready(function(){
    $.mask.definitions['h']= "[\-]"
}); 

with mask="?h999999999999999999999999999999" in <p:inputMask>

None of these has ever worked as intended. I'm probably misunderstanding how it works

0 个答案:

没有答案