You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Duke Ronlund <du...@bigpond.com> on 2002/07/13 07:18:48 UTC
Retrieving elements in order
Hi,
I would like to be able to build my webapps main menu from the <forward
.../> elements in struts-config, and display them in the same order that
they appear in the config file.
I can retreive this information by calling
ApplicationConfig.findForwardConfigs(), but as the underlying collection
is a HashMap, order is not guaranteed.
I assume that next best thing to use is the commons digester, does the
digester retain the order of the xml file it parses?
Can anyone offer any suggestions or alternatives?
TIA
Duke Ronlund
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Retrieving elements in order
Posted by Stan Baranek <st...@gene.COM>.
Use a TreeMap to keep them in sorted order and write a tag to spit out the html.
It's also handy to sort with case-insensitive like:
TreeMap tmpMap = new TreeMap(String.CASE_INSENSITIVE_ORDER);
tmpMap.putAll(Map map);
Duke Ronlund wrote:
> Hi,
>
> I would like to be able to build my webapps main menu from the <forward
> .../> elements in struts-config, and display them in the same order that
> they appear in the config file.
>
> I can retreive this information by calling
> ApplicationConfig.findForwardConfigs(), but as the underlying collection
> is a HashMap, order is not guaranteed.
>
> I assume that next best thing to use is the commons digester, does the
> digester retain the order of the xml file it parses?
>
> Can anyone offer any suggestions or alternatives?
>
> TIA
>
> Duke Ronlund
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Retrieving elements in order
Posted by John Yu <jo...@scioworks.com>.
At 09:00 am 13-07-2002 -0700, you wrote:
>Because Digester is based on a SAX parser, it definitely maintains order
>while the parsing is happening. You'll need to ensure that your Rule
>instances save the forwards in some collection that also maintains order
>(like a List instead of a Map).
Or use something like SequencedHashMap from commons-collections
(nightly-build).
>Craig
--
John Yu Scioworks Technologies
e: john@scioworks.com w: +(65) 873 5989
w: http://www.scioworks.com m: +(65) 9782 9610
Scioworks Camino - "Don't develop Struts Apps without it!"
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: Retrieving elements in order
Posted by "Craig R. McClanahan" <cr...@apache.org>.
On 13 Jul 2002, Duke Ronlund wrote:
> Date: 13 Jul 2002 15:18:48 +1000
> From: Duke Ronlund <du...@bigpond.com>
> Reply-To: Struts Users Mailing List <st...@jakarta.apache.org>
> To: Struts Users Mailing List <st...@jakarta.apache.org>
> Subject: Retrieving <forward .../> elements in order
>
> Hi,
>
> I would like to be able to build my webapps main menu from the <forward
> .../> elements in struts-config, and display them in the same order that
> they appear in the config file.
>
> I can retreive this information by calling
> ApplicationConfig.findForwardConfigs(), but as the underlying collection
> is a HashMap, order is not guaranteed.
>
> I assume that next best thing to use is the commons digester, does the
> digester retain the order of the xml file it parses?
>
Because Digester is based on a SAX parser, it definitely maintains order
while the parsing is happening. You'll need to ensure that your Rule
instances save the forwards in some collection that also maintains order
(like a List instead of a Map).
> Can anyone offer any suggestions or alternatives?
>
> TIA
>
> Duke Ronlund
>
Craig
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>