question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

inputMask: doesn't work if created programmatically

See original GitHub issue

Describe the bug

I have an application that’s built on primefaces 12 to generate dynamic pages based on backend database, and I create InputMask as follows :

 Application application = FacesContext.getCurrentInstance().getApplication();
    InputMask inputNumber = (InputMask) application.createComponent(InputMask.COMPONENT_TYPE);
    inputNumber.setMask("999999999999999"); 
    inputNumber.setSlotChar("");
    inputNumber.setAutoClear(false);
    inputNumber.setValidateMask(false);
    inputNumber.setId(property.getSymbolicName());
    inputNumber.setMaxlength(15);
    myPanelGrid().getChildren().add(inputNumber);

Issue : the mask doesn’t work in my xhtml page and I get error in console :

Widget class ‘InputMask’ not found!

So I tried manually to import the inputMask script as follows :

<h:outputScript library="primefaces" name="inputmask/inputmask.js" target="head" />
    <h:outputScript library="primefaces" name="validation/validation.js" target="head" />

But it didn’t work also The only working workaround was to manually add in page a hidden inputMask component as follows :

<p:inputMask style="display:none"/>

Question : How to make the inputMask works fine without this workaround ?

Reproducer

No response

Expected behavior

No response

PrimeFaces edition

Community

PrimeFaces version

12.0.0

Theme

No response

JSF implementation

Mojarra

JSF version

2.3.9

Java version

1.8

Browser(s)

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
mellowarecommented, Oct 19, 2022

Nevermind I see it now: image

1reaction
Rapstercommented, Oct 19, 2022

If you’re open to an alternative, you might be also interested in this: https://www.primefaces.org/showcase-ext/sections/dynaform/basicUsage.jsf

Read more comments on GitHub >

github_iconTop Results From Across the Web

Primefaces InputMask doesn't work if created programmatically
I have an application that's built on primefaces 12 to generate dynamic pages based on backend database, and I create InputMask as follows...
Read more >
Masking does not work with form elements created with jQuery
Hi, I am adding a row to an input table using the following jQuery code. Unfortunately, the masking does not work for the...
Read more >
Using input masks in React Native - LogRocket Blog
Implement input masks in React Native to develop user-friendly input constraints such as entering data according to a pre-defined format.
Read more >
Input Mask | WinForms Controls - DevExpress Documentation
Input masks restrict data input and allow you to guide users to enter correct values. For instance, you can apply the phone number ......
Read more >
How to Use an Input Mask in Microsoft Access ... - YouTube
In this video, I will teach you how to use an Input Mask in your Microsoft Access tables and forms. We will create...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found