You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Joe Germuska <Jo...@Germuska.com> on 2004/06/06 17:49:35 UTC

Re: [Raw newbie] Struts/JSTL - A cople of urgent question (Message resources)

It may not be a Struts question, but if you're using a post-1.1 
Struts build, you may find the DigestingPlugIn an easy way to put 
together lists for use in menus.

The DigestingPlugIn simply uses Digester to process an XML file and 
put something in the application context; the simplest possible use 
case is to use one plugin for each menu you need and put lists of 
LabelValueBeans into application context.  (You can get fancier if 
you want.)

Then you'd have a separate plugin for each domain of measurement 
(distance, area, volume, etc) or locale.

You could probably actually use the DigestingPlugIn without post 
Struts-1.1, except that you'd need your own LabelValueBean class (the 
one in Struts lacked a no-arg constructor at the time of the 1.1 
release.)  If you just want it in a package, you could grab the 
version from http://demo.jgsullivan.com/struts/ which is the same in 
spirit.

Hm.  Now that I read a little more, I wonder if you're also looking 
for a localization solution?  In any case, using the DigestingPlugIn, 
you could make a slightly smarter bean which was localized.  It would 
take more code, but nothing too hard to put together.

Joe


At 7:55 AM -0700 6/6/04, Riyad Kalla wrote:
>This doesn't necessarily sound like a Struts question, so I'll 
>answer it in the general terms:
>
>1) Create your ResourceBundle for that properties file containing 
>all your measurement information, then from that get the enumeration 
>from "getKeys" then cycle over the keys getting the values, doing 
>your logic on each value (if contains DISTANCE then blah).
>
>2) You can call get normally here but when you get back your result, 
>call a string.split(",") on it to get back a 2-element array, one 
>with "en_US" in it and the other with "USA" in it, then you do your 
>logic to make one the display variable and one the logical variable 
>in the system. NOTE: String.split is insanely fast, actually all of 
>the regexp package is insanely fast, I tried benchmarking it once to 
>see if I should implement a much simplier routine for my parser, and 
>the regexp package blew me away, it was almost rediculous how fast 
>it was.
>
>Johan Wasserman - BCX - Infrastructure Services wrote:
>
>>As a RAW newbie:
>>How do I buid an ArayList of properties for a menu?
>>for example;
>>I have a resource file containing:
>>DISTANCE_MILE=Mile
>>DISTANCE_KILO=Kilometre
>>DISTANCE_FEET=Feet
>>DISTANCE_METRE=Metre
>>AREA_SQ_FOOT=Sqare Foot
>>AREA_SQ_METRE=Square Metre
>>VOLUME_QUBIC_INCH=q'
>>VOLUME_QUBIC_METRE=m2
>>
>>now, I need to (from a class), get the resource bundle and build an
>>araylist of (key, value) for DISTANCE* so that only the distance
>>parameters show up in my list.
>>
>>To do this even more trickier.... if I have something like:
>>LANG_EN_US=en_US, USA
>>LANG_EN_UK=en_UK, England
>>...etc
>>
>>how do I have the en_US (constant) as the value and USA (variable,
>>depending on language) as the display?
>>
>>get my drift?
>>
>>Thank you for a wonderrful forum (MSDN, go suck eggs!)
>>
>>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org


-- 
Joe Germuska            
Joe@Germuska.com  
http://blog.germuska.com    
"In fact, when I die, if I don't hear 'A Love Supreme,' I'll turn 
back; I'll know I'm in the wrong place."
    - Carlos Santana

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org