Mask part of value returned from DB
5 posts
• Page 1 of 1
Mask part of value returned from DB
Hello!
I have a screen with a grid that is populated from the DB.
The grid has a column that shows values, i want to mask part of the value.
For example:
the value is: 123456789
want to see it as ******789
Is it possible ?
how do i do it ?
Thank You
I have a screen with a grid that is populated from the DB.
The grid has a column that shows values, i want to mask part of the value.
For example:
the value is: 123456789
want to see it as ******789
Is it possible ?
how do i do it ?
Thank You
- reversedr
- Posts: 35
- Joined: Tue Oct 23, 2018 11:03 am
Re: Mask part of value returned from DB
Should the value be read-only or do you have an editor for this column?
and if, should the editor show the masked value or the original value?
and if, should the editor show the masked value or the original value?
-
Support@SIB - Posts: 353
- Joined: Mon Sep 28, 2009 1:56 pm
Re: Mask part of value returned from DB
The grid is readonly, no editor for this column.
Thank you
Thank you
- reversedr
- Posts: 35
- Joined: Tue Oct 23, 2018 11:03 am
Re: Mask part of value returned from DB
You have different options:
Simple hide the orignal column if you want. With all options it's possible to use an editor for the original column.
- Use a view for fetching data
- Add a virtual column to your select statement, via DBStoragestorage.setAdditionalQueryColumns(new String[] {"1234 as pin_code_hidden"});
This requires a db function to change the pin. This method is db (in)dependent, but works great. - Use the calculate row eventstorage.getMetaData().addColumnMetaData(new ColumnMetaData("PIN_CODE_HIDDEN"));
storage.eventCalculateRow().addListener(this, "doCalculate");
public void doCalculate(StorageEvent pEvent)
{
IBean bnNew = pEvent.getNew();
bnNew.put("PIN_CODE_HIDDEN", hide(bnNew.get("PIN_CODE")));
}
private Object hide(Object pValue)
{
if (pValue == null)
{
return null;
}
String value = pValue.toString();
return StringUtil.lpad(value.substring(value.length() - 3), 10, '*');
}
Simple hide the orignal column if you want. With all options it's possible to use an editor for the original column.
-
Support@SIB - Posts: 353
- Joined: Mon Sep 28, 2009 1:56 pm
Re: Mask part of value returned from DB
Thanks for you help!
- reversedr
- Posts: 35
- Joined: Tue Oct 23, 2018 11:03 am
5 posts
• Page 1 of 1