Details
-
Improvement
-
Status: Closed
-
Normal
-
Resolution: Fixed
-
None
-
None
-
None
Description
In a project, I implemented a JSP tag library which replaces the
embedded text containing variables like the following:
<ns1:messagesReplace>Hello, ${name}!</ns1:messagesReplace>
or
<%-- suppose ${document.greeting} rendered as "Hello, ${name}" from the
text document property directly.. --%>
<ns1:messagesReplace><c:out
value="${document.greeting}"/></ns1:messagesReplace>
By default, the tag resolves all the variables by using the current java
resource bundle (via JSTL's LocalizationContext).
The tag also has an attribute ("bundle") to set a custom resource bundle
object or another attribute ("basename") for a bundle basename string.
Also, some people want to have a placeholder feature like the following:
"I have to mix CMS content with data I receive from a rest service. I want the editor to be able to add a placemarker to the text where the data from the restservice can be injected. For instance a CMS document that contains the string "Your telephone number is %s", where the content for %s is delivered by a rest service (e.g. "012-3456789")."
I think this JSTL tag library can be used for that use case, too.
This tag can be used in a template page and a custom resource bundle (see [1] as an example) can be provided in the component code for the tag.