In JSTL when we use a tag like
<fmt:message key="my.pending.key"/>
And if the resource bundle does not have an entry for that key, the HTML output will look like ???my.pending.key???
I know this helps in identifying the missing entries in the resource bundle and hence one can go and add them. But is there a way to tell JSTL not to render the question marks and just render the value as my.pending.key
In a prototype, I need to use a run time translator service provided by the customer, and for certain strings that have capitalized strings the translated value remains same and the service does not add such strings to the bundle. The expected behavior is that if you don't find the translation display the source as is.
I have discussed with the customer to add the strings to bundle even if there is no translation, but in turn I was asked to see if I can render the original text as is. And JSTL adds the question marks.
One approach you might take is to create a tag file that would handle this for you. The tag file could use the <fmt:message> tag with the var attribute to assign the value to a scope variable. You can check the variable, and if needed, use the key directly rather than the error output.
your suggestion seems much elegant than the if/else check that I am doing in JSTL. These if/else are making my JSTL tags messy
Can you please elaborate with a bit more if you do not mind.
How would such custom tag syntax looks like? and how will the code behind the tag looks like?
Writing tag files is easy. Look up a tutorial or in the JSP Spec.
Within the tag file, assuming that it is defined with an attribute named key, you can use:This will write the result of the lookup into scoped variable value, which you can then test.