I am trying to create a FormItem that mostly hides the value.... for example:
SSN is 123-45-6789
but I would like it to display as
***-**-6789 (or *****6789)
another example might be a credit card number that would show as *************1234
In all of our forms, we require the user to click an edit button to go into edit mode and this calls setCanEdit(true) on all the fields. I want to hide the full value unless it's being edited. This seems like a fairly common usage and maybe someone has done it before?
What I want is when not in edit mode, the SSN would display hidden like *****6789 but also have way to see the full value with user interaction (maybe click a picker icon/button). Then, when in edit mode, it shows the full editable value as usual.
I coded this all up by extending TextItem and it works. I used a PickerIcon with setNeverDisable(true) so when clicked it shows the complete value in a dialog. When in edit mode, I hide the PickerIcon and show the full value as usual. This works but the way I did it is causing all kinds of side effects (form.reset() doesn't work correctly, rememberValues() was remembering the hidden value, the validators were triggering on the obfuscated string) and was causing me to override a bunch of extra methods to account for the "dual-value" nature of the FormItem.
My solution works, but it's ugly/messy and I have to believe there is an easier way to accomplish this. The other way I thought I could do it was to actually have 2 FormItems in the form... one holds the real value and one holds the obfuscated value. The obfuscated one would have setShouldSaveValue(false) called on it and when we go to/from edit mode we would just hide/show the proper field. I think this might work but I'm not sure about other side effects.
Thoughts? Ideas? I can post my code if anyne wants to see it but I'm really looking for a different idea on how to do this.
Thanks,
Brian
SSN is 123-45-6789
but I would like it to display as
***-**-6789 (or *****6789)
another example might be a credit card number that would show as *************1234
In all of our forms, we require the user to click an edit button to go into edit mode and this calls setCanEdit(true) on all the fields. I want to hide the full value unless it's being edited. This seems like a fairly common usage and maybe someone has done it before?
What I want is when not in edit mode, the SSN would display hidden like *****6789 but also have way to see the full value with user interaction (maybe click a picker icon/button). Then, when in edit mode, it shows the full editable value as usual.
I coded this all up by extending TextItem and it works. I used a PickerIcon with setNeverDisable(true) so when clicked it shows the complete value in a dialog. When in edit mode, I hide the PickerIcon and show the full value as usual. This works but the way I did it is causing all kinds of side effects (form.reset() doesn't work correctly, rememberValues() was remembering the hidden value, the validators were triggering on the obfuscated string) and was causing me to override a bunch of extra methods to account for the "dual-value" nature of the FormItem.
My solution works, but it's ugly/messy and I have to believe there is an easier way to accomplish this. The other way I thought I could do it was to actually have 2 FormItems in the form... one holds the real value and one holds the obfuscated value. The obfuscated one would have setShouldSaveValue(false) called on it and when we go to/from edit mode we would just hide/show the proper field. I think this might work but I'm not sure about other side effects.
Thoughts? Ideas? I can post my code if anyne wants to see it but I'm really looking for a different idea on how to do this.
Thanks,
Brian