Raible's Wiki

Raible Designs
Wiki Home
News
Recent Changes

AppFuse

Homepage
  - Korean
  - Chinese
  - Italian
  - Japanese

QuickStart Guide
  - Chinese
  - French
  - German
  - Italian
  - Korean
  - Portuguese
  - Spanish
  - Japanese

User Guide
  - Korean
  - Chinese

Tutorials
  - Chinese
  - German
  - Italian
  - Korean
  - Portuguese
  - Spanish

FAQ
  - Korean

Latest Downloads

Other Applications

Struts Resume
Security Example
Struts Menu

Set your name in
UserPreferences


Referenced by
...nobody




JSPWiki v2.2.33

[RSS]


Hide Menu

ConstantsTag


Difference between version 10 and version 5:

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 23 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 my Contants class (and using &lt;%=Contants.VARNAME%&gt;). With this tag, both of the following work:
{{{Scriptlet: <%=VARNAME%>, JSTL: <c:out value="${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 &lt;cache&gt; tags.''
!Files Needed for Tag Library
* [1] ConstantsTag.java
* [2] ConstantsTei.java - exposes variables as attributes
----
!!ConstantsTag.java [#1]
At line 181 added 2 lines.
----
!!ConstantsTei.java [#2]
At line 158 changed 1 line.
{[Java2HtmlPlugin
[{Java2HtmlPlugin
At line 257 added 2 lines.
Also see [my blog post|http://www.raibledesigns.com/page/rd?anchor=useless_tag_library].

Back to ConstantsTag, or to the Page History.