Difference between
version 7
and
version 6:
At line 3 added 1 line. |
Inspired by <a href="http://www.raibledesigns.com/page/rd?anchor=how_do_you_manage_your">this post</a>, I wrote a tag library to expose the fields of my Contants.java class to my JSPs. It allows a user to specify a single variable using: |
At line 5 added 19 lines. |
{{{ |
<appfuse:constants var="USER_KEY"/> |
}}} |
|
Or all variables: |
|
{{{ |
<appfuse:constants/> |
}}} |
|
By default, it exposes the values from the Contants class imported into the tag library, but also allows a className variable to specify a different class. The main reason I wrote this was to prove it was possible. The second reason was to get around importing Constants and then using |
|
{{{<%=Constants.VARNAME%>}}} |
|
The only thing it gives you over the import/scriptlet way is to expose the attribute to different scopes - i.e. page for JSTL. After writing it, I think it's a fairly useless tag library - I don't know if I'll ever use it, but maybe someone else will find it useful. |
|
;:''BTW, you need to use it on the JSP you plan to use it in a scriptlet and you can't wrap it with oscache's <cache> tags.'' |
|
|
Back to ConstantsTag,
or to the Page History.
|