vaadin-component-factory / input-mask

Vaadin Flow integration of imaskjs library.
Apache License 2.0
1 stars 5 forks source link

Linking the textfield's Binder to the unmaskedValue #8

Closed mil3stone closed 11 months ago

mil3stone commented 1 year ago

We were wondering if it is possible to use your add-on to mask an input but send the unmasked value back to the Binder/server. In our scenario, we want to (among other masks) pretty print an IBAN during input, but only want the unmasked IBAN (i.e. without the spaces and so on) to be sent to the server side for further processing.

All our tries ended up by some sort of listening to the accept event and sending each unmaskedValue to the server - which would cause heavy traffic between browser and server.

Listening to the change event and grab-and-send the unmaskedValue to the server results in having the value on server side just after the Binder has done its getValue/setValue thing. Which is way too late.

jcgueriaud1 commented 1 year ago

For this, I'm using a converter that converts the bank account on the server side. (basically I'm formatting and revert the format on the server side). If you really want to avoid this, you can probably do this if you wrap your textfield in a CustomField and instead of using the textfield value use the unmasked value. (You will probably have some issue with the timing)

mil3stone commented 1 year ago

If it was a static mask, we'd be able to do that. But our environment is highly dynamic and IBAN is just one small example. Just think of direct dialing but showing the whole telephone number while typing; or customer IDs with a pre-/suffix and only the non-pre/suffix part should go into the appended workflow...

Our users can define their own custom patterns and want to have the unmasked value on the server side for further use in their workflow. Keeping that in mind, we'd have to create an additional custom converter, which converts the masked value back to unmasked by accessing the defined custom pattern mask and try to revert it. This would open room for many errors, that's why we want to access (and use) the unmasked value directly on the server side.

If you think this sounds like a good use case and all you need are some "Expert on demand" hours, we would be happy to provide them.

TatuLund commented 1 year ago

If you think this sounds like a good use case and all you need are some "Expert on demand" hours, we would be happy to provide them.

It could be possible. If you have subscription, just go ahead and open a case at our portal https://support.vaadin.com