java - adding second level data in properties file -
what have properties file below.
welcome.properties
admin = admin welcomeadmin = welcome admin editadmin = edit admin as have repeated admin word, want use below.
admin = admin welcomeadmin = welcome #{admin} editadmin = edit #{admin} so if change @ 1 place i.e. @ admin = admin, places reflect.
any idea/ suggestion how done appreciated.
as per today, classic resourcebundle class doesn't support named parameters , substitution, rather supports simple placeholders of {0} type in key-value pairs of bundles, substituted using messageformat#format.
in light if replace welcome #{admin} welcome {0} you'd able achieve functionality seek using 1 of following:
jsf's
<h:outputformat>:<h:outputformat value="#{msg.welcomeadmin}"> <f:param value="#{msg.admin}" /> </h:outputformat>jstl's
<fmt:message>:<fmt:message key="msg.welcomeadmin"> <fmt:param value="#{msg.admin}"> </fmt:message>
you create own el function, or tag handler, or ui component, or make use of messageformat class methods in beans, etc. of course, extend resourcebundle class support named parameters , return message named parameters parsed.
suggested reading:
Comments
Post a Comment