on 11-10-2008 2:29 PM
Hi,
I have some context attribute(build in decimal type), and want to configure output view(grouping and decimal separators) of this value on UI components for different users using ISimpleTypeModifiable interface. I didn't find any setter methods for Formatter(NumberFormat interface). So, I have tried to use setLocale method(different locales have different separators: "RU" locale output for ex. - 123 456,78), but it throws UnsupportedOperationException. Here is some simple code to describe this situation:
ISimpleTypeModifiable type = attrInfo.getModifiableSimpleType();
type.setLocale(new Locale("some locale"));
type.setFormat("some format");
If there is some other way to configure output view for decimal attributes without changing attribute type?
Thanks
Edited by: Mikhail Udalov on Nov 10, 2008 3:30 PM
Edited by: Mikhail Udalov on Nov 10, 2008 3:30 PM
Hi, Mikhail!
The simplest solution is to configure (or change in runtime - if it possible) user's locale.
Also you can create calculated read only attribute of type string and use it for presenting your decimal value in right format. Something like this:
// get method of calculated attribute
final NumberFormat format = NumberFormat.getInstance(locale);
return format.format(numericValue);
More one solution is creating "right localized" attribute dynamically:
final ISimpleType decimalType = attrInfo.getSimpleType(); // some decimal attribute created in designer
final ISimpleTypeModifiable localizedDecimal = decimalType.cloneType(locale);
localizedDecimal.setFormat("some format"); // specify format if need
nodeInfo.addAttribute("DecimalValue", localizedDecimal);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Have you tried with a dictionary type?
Regards
Ayyapparaj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
I assume that you are getting the values as decimal and want to display it to users in some user-specific formats:
for(int i=0; i<wdContext.node<nodename>().size();i++)
{
DecimalFormat d = new DecimalFormat("#,##,###");
String value = d.format(wdContext.node<nodename>(i).get<DecimalAttribute>());;
//Assign the above string value to the field that you want to display to the user.
}
Regards,
Murtuza
The reason was that
attrInfo.getModifiableSimpleType()
returns ModifiableSimpleType instance on runtime(not DdTypeDecimal as I thought before) that wraps DdTypeDecimal instance and throws UnsupportedOperationException on setLocale method. setFormat works fine but I still can't change decimal and grouping separators
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.