Consider that I have a List
of AccountVO
object which must be displayed in grid
AccountVO{
bankCode; //which could be HSB,CITY
amout;
...
}
In resource bundle I have
bank.name.HSB = The HSB Bank
bank.name.CITY = The CITY Bank
......
bank.name.HSB = بانک اچ اس بی
bank.name.CITY = بانک شهر
I tried to dynamically change grid name in gridColumn
tag. so I used getText
in gridColumn
<sjg:gridColumn name="%{getText('bank.name.'+bankCode)}" .... />
It did not work.
When I see the generated code I find below:
options_gridtable_colmodels_بانک شهر = {};
options_gridtable_colmodels_بانک شهر.name = "بانک شهر";
options_gridtable_colmodels_بانک شهر.jsonmap = "بانک شهر";
As you can see the javascript variables now have the i18n names in them, which is not correct.
To solve this, I use getText
in action. For example:
for(List<Account>: account ){
account.setI18nBankName( getText('bank.name.'+ account.getBankCode() ) );
}
Now I can use:
<sjg:gridColumn name="i18nBankName" .... />
As you can see I need extra loop and some dummy property.
Is there better way?!