Variable substitution JSF Resource Bundle property file

大憨熊 提交于 2020-01-05 09:02:19

问题


Can i do something like in JSF Resource Bundle property text file:

receptionContact=Reception
reservationContact=Reservation

receptionEmail={receptionContact}
reservationEmail={reservationContact}

回答1:


You can parameterize your resource bundles, but no reflective reuse of values by keys. Please have a look on this: https://code.google.com/p/reflectiveresourcebundle/

With that, you don't have repeat your self!

Without:

company.service.phone=555-1212
company.service.email=help@company.com
my.error.message=Problem accessing account!\
                 Please call customer service at 555-1212 \
                 or email us at help@company.com 

With:

company.service.phone=555-1212
company.service.email=help@company.com
my.error.message=Problem accessing account!\
                 Please call customer service at ${company.service.phone} \
                 or email us at ${company.service.email}

Here is another interesting tutorial about formatting.



来源:https://stackoverflow.com/questions/8139250/variable-substitution-jsf-resource-bundle-property-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!