简体   繁体   English

Primefaces inputMask仅接受hex

[英]Primefaces inputMask accept only hex

I'm facing a terrible problem with the update of primefaces from 6.2.5 to 7.0.4. 我正面临着从6.2.5到7.0.4更新主要表面的可怕问题。 Before i was using a inputMask like this way: 在我像这样使用inputMask之前:

<p:inputMask id="input" value="#{bean.inputs.id}" mask="^^ ^^ ^^ ^^ ^^"
             requiredMessage="#{label.lblRequired}" >
    <f:validator validatorId="Validator"/>
</p:inputMask>

there is also an javascript part where i definie the usage of "^" 还有一个javascript部分,我定义“^”的用法

$.mask.definitions['^'] = '[A-Fa-f0-9]';

with primefaces 7.0.4 i can't use this pattern anymore as you can see in this commit: Link to primefaces github . 使用primefaces 7.0.4我不能再使用这种模式了,你可以在这个提交中看到: 链接到primefaces github Additional if i use this way, there is no error but the value keeps beeing empty but on the webpage it is filled the right way. 另外,如果我使用这种方式,没有错误,但值保持空白但在网页上它以正确的方式填充。

My question would be if there is any other way to add a regex to every field of my input? 我的问题是,是否有任何其他方法可以为我的输入的每个字段添加正则表达式? Or is there a pattern that i am missing 或者是否有一种我缺失的模式

What i tried so fare is: 我试过这样的票价是:

  1. add <f:validateRegex pattern="[regex]"/> --> no good 添加<f:validateRegex pattern="[regex]"/> - >没有好处
  2. add <p:keyFilter regEx="[regex]" /> --> working only on inputText 添加<p:keyFilter regEx="[regex]" /> - >仅在inputText上工作
  3. trying to add regex for each "^" --> no good 试图为每个“^”添加正则表达式 - >没有好处

You are correct that it was broken in PrimeFaces 7.0 with this security fix: https://github.com/primefaces/primefaces/issues/3234 你使用这个安全修复程序在PrimeFaces 7.0中破坏了它是正确的: https//github.com/primefaces/primefaces/issues/3234

Comment in that thread from the developer who patched this security hole. 从修补此安全漏洞的开发人员那里获得评论。

jquery.maskedinput lets you define your own rules aka mask definitions, eg ~ can be defined to be mapped to + or -. jquery.maskedinput允许您定义自己的规则,也就是掩码定义,例如〜可以定义为映射到+或 - 。 Example from https://github.com/digitalBush/jquery.maskedinput 来自https://github.com/digitalBush/jquery.maskedinput的示例

jQuery(function($){    
   $.mask.definitions['~']='[+-]';   
   $("#eyescript").mask("~9.99 ~9.99 999"); 
}); 

However, PrimeFaces does not seem to implement this feature. 但是,PrimeFaces似乎没有实现此功能。 So I ignored it in my commit. 所以我在提交中忽略了它。

So it appears you should comment on that bug ticket saying it caused a regression issue. 因此,您似乎应该对该错误故障单进行评论,说它会导致回归问题。

Update 9/2/2019 : This has been fixed for PF 7.0.8 and 7.1: https://github.com/primefaces/primefaces/issues/5105 更新9/2/2019 :已针对PF 7.0.8和7.1修复此问题: https//github.com/primefaces/primefaces/issues/5105

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM