I understand the usage of standard fmt:message
Tag i.e we define something like this in the JSP:
<fmt:setBundle basename="ResourceBundles.ValidationErrorMessages" var="errorMessages" />
<fmt:message key="${error.value}" bundle="${errorMessages}" />
Suppose error.Value = "MQ2009"
My properties file named "ValidationErrorMessages" has following entry
MQ2009 = MQ time out
Now my requirement is to have something like
MQ2009 = Mq timeout happened for message {messagename}.
Can I define the messagename
variable dynamically? I.e at runtime, messagename
will be available in request scope and it should be substituted in the properties file.
How can I do this? Do I need a custom tag or does Java EE provides this feature which I am not aware off?
You can define properties like
MQ2009 = Mq timeout happened for {0}
and then
<fmt:message key="MQ2009" var="val" >
<fmt:param value="${valueComingFromSomeParameter}"/>
</fmt:message>
and then
<c:out value="${val}"/>
In you properties file
MQ2009 = Mq timeout happened for message {0}
Then you can nest a <fmt:param value="${messagename}"/>
tag withing <fmt:message
tag, where messagename
is in request scope.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With