Skip to content

Instantly share code, notes, and snippets.

@jesperronn
Created December 17, 2009 22:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jesperronn/259098 to your computer and use it in GitHub Desktop.
Save jesperronn/259098 to your computer and use it in GitHub Desktop.
// why should this be so many lines??
<c:choose>
<c:when test="${isKvik}">
<content:resourceBundle
resourceBundle="jahiatemplates.virk_templates"
resourceName="sidebar.kvik_mit_virk.header" defaultValue="BusinessInDenmark" />
</c:when>
<c:otherwise>
<content:resourceBundle
resourceBundle="jahiatemplates.virk_templates"
resourceName="sidebar.mit_virk.header" defaultValue="Mit Virk.dk" />
</c:otherwise>
</c:choose>
<t:lookup test="isKvik" keyIfTrue="sidebar.kvik_mit_virk_header" keyIfFalse="sidebar.mit_virk_header" defaultValue="Mit Virk.dk"/>
/* I guess two primary reasons.
1) the if/then construct
2) the lookup of text keys in a property file
filename: src/main/resources/jahiatemplates/virk_templates.properties
Now, what if we could replace the first construct with an EL expression: */
${ if(isKvik) ? a : b}
/* And what if we could replace the resource lookup in taglib style
with a method that could be called via the EL JSTL syntax style:
*/
${ lookup("sidebar.kvik_mit_virk.header") }
/* This would probably require an include line in the top of the file
So now we can combine the two into:
*/
${ if(isKvik) ? lookup("sidebar.kvik_mit_virk.header") : lookup("sidebar.mit_virk.header") }
// Which could then be slightly shortened:
${ lookup( (isKvik)? "sidebar.kvik_mit_virk.header" : "sidebar.mit_virk.header" ) }
// and probably more readable:
String lookupKey = "sidebar.mit_virk.header";
if(isKvik){ lookupKey = "kvik_" + lookupKey;}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment