Comments (13)
@melloware oh yes this version I also tested and it is working fine!
from primefaces.
In PrimeFacess 6.1 it used the dead and deprecated jquery.mask.js
plugin. It was upgraded to the modern InputMask plugin with this one: #6062
The newer InputMask is kept up to date, had way more features and bugfixes as you can see that PR closed 4 previous issues.
But let me revisit this to see what can be done as you have seen from this issue which is why we strip the optional "slotChar" #6469
from primefaces.
Cc @tuerker who originally requested the fix that you mentioned above.
from primefaces.
Awesome, thank you! I can see many scenarios where removing the slotChar from the incomplete masked input value would be the right move and why it was implemented this way. But as I mentioned there are some cases where keeping the optional slotChar had some usefulness. Thats why I suggested that it should be interesting to have an option for both solutions.
from primefaces.
@cfortes thanks for the report. Also do you need a workaround for 13.x to get this working the way it was? I can provide one if you don't have one you are already using?
from primefaces.
Yes I'd like a workaround! I've been trying to find one but nothing really works
from primefaces.
Ok I will post here tomorrow how you can make it work.
from primefaces.
@cfortes give this a try just unzip and run mvn clean jetty:run
and go to http://localhost:8080/
pf-11958.zip
basically i override the renderer to only strip out the slotChar IF you are using an "optional" mask.
public class SlotCharInputMaskRenderer extends InputMaskRenderer {
@Override
public void decode(FacesContext context, UIComponent component) {
InputMask inputMask = (InputMask) component;
if (!shouldDecode(inputMask)) {
return;
}
decodeBehaviors(context, inputMask);
String clientId = inputMask.getClientId(context);
String submittedValue = context.getExternalContext().getRequestParameterMap().get(clientId);
if (submittedValue != null) {
// strip mask characters in case of optional values
String mask = inputMask.getMask();
if (mask.contains("[") || mask.contains("]")) {
submittedValue = submittedValue.replace(inputMask.getSlotChar(), Constants.EMPTY_STRING);
}
if (inputMask.isValidateMask() && !LangUtils.isEmpty(submittedValue) && LangUtils.isNotBlank(mask)) {
Pattern pattern = translateMaskIntoRegex(context, mask);
if (!pattern.matcher(submittedValue).matches()) {
submittedValue = Constants.EMPTY_STRING;
}
}
inputMask.setSubmittedValue(submittedValue);
}
}
}
from primefaces.
@melloware thank you it worked!
I only have one question, is it ok to force autoClear = false
when there is optional mask? #11959
I'm asking because isn't there a possibility of the user input an invalid value and it won't be cleared when the mask is optional?
from primefaces.
So in the renderer we do this...
// autoclear must be false when using optional mask
boolean autoClear = inputMask.isAutoClear();
if (mask.contains("[") || mask.contains("]")) {
autoClear = false;
}
Basically if you are using optional mask it automatically sets AutoClear="false".
Do you think that is still OK?
from primefaces.
@melloware I've done the following test:
<p:inputMask
value="#{exampleController.value}"
mask="(99) 9999[9]-9999"
autoClear="true">
</p:inputMask>
- the mask
"(99) 9999[9]-9999"
is used for phone numbers, and its value has an optional extra digit - I've inputed
"000"
an incomplete and invalid value. it has been validated correctly, it has been recognized as invalid and sent null to the server - but it kept the incorrect value on the screen
from primefaces.
did you try it with validateMask="false"
? The optionals make server side prevention tough. In 6.1 we were not defending the security of someone just doing a FORM POST and sending you an invalid value for a mask so we prevent invalid submissions.
from primefaces.
Also I just tested and mine is not keeping the incorrect version on the screen?
from primefaces.
Related Issues (20)
- CSV: Date validation requires legacy Calendar
- Wrong Javadoc for InputMaskRenderer#translateMaskIntoRegex() HOT 6
- TabMenu: Incorrect border classes applied
- DatePicker: yearNavigator is no longer rendered as a dropdown HOT 5
- DataTable: Allow using custom icons for p:rowToggler HOT 3
- Confirm: message facet HOT 5
- jakarta and facelet-taglib version HOT 5
- Confirm: event.currentTarget is the incorrect button HOT 2
- AutoComplete: Float label and multiple="true" not working
- Remove locales JS from datepicker showcase
- Auto detect HTML5_COMPLIANCE HOT 5
- Sticky: Filtering column in p:dataTable/p:column, using sticky feature, do not allow user input. Must use scrolling to activate HOT 10
- Showcase: Error when running locally after a few minutes HOT 14
- FileUpload component has dependency on Apache POI HOT 1
- OverlayPanel: Memory Leak on destroy HOT 1
- TabView: Memory leak on Tab close
- ImportConstants/ImportEnum: Preserve order of constants HOT 1
- Barcode: default QR code size HOT 7
- Primefaces V14 - p:fileUpload drag/drop no triggers listener HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from primefaces.