struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eddie Bush <ekb...@swbell.net>
Subject Re: preserve Forward order
Date Sat, 21 Sep 2002 16:24:47 GMT
Well, I'm not sure what sort of collection those are kept in.  It may 
not be ordered.   My (pure) guess is that those get stored in a Hashmap 
of sorts.  That being the case, I don't think there's a way to determine 
their original order - you'd have to "cook something up".  You could:
    - write a plugin to build an object-graph representing your 
navigation console
    - hack struts to use a different sort of collection

The plugin idea has some merit to it.  You'll get a reference to the 
application configuration for whichever module you're in.  You could use 
that to determine your links etc.  What you'd probably do is something 
along these lines:

- arrive at a design for your heirarchy
- arrive at a deisgn for an XML file that models that heirarchy
- use digester to parse the XML and create/populate your beans
- iterate through your beans and use some attribute of the bean to do a 
lookup in the application config and retrieve the links you need
- set your bean properties per the action
- stuff your "top-level" bean out into application scope so you can 
reference it later

Help any?

Billy Ng wrote:

>I knew somebody would ask me why :-)
>
>Okay, I am using the String[] that returns from mapping.findForwards() to
>generate links in the left nav bar.  This way, I will only generate the
>links for the Action I call.  For example,
>
>  <action path="/project"
>          type="com.evebill.billyng.ui.about_me.AboutMeBase"
>          name="AboutMeAction">
>   <forward name="bridge" path="/jsp/about_me/bridge.jsp"/>
>   <forward name="subway" path="/jsp/about_me/subway.jsp"/>
>   <forward name="library" path="/jsp/about_me/library.jsp"/>
>  </action>
>
>String[] forwards = mapping.findForwards();
>for (int i=0; i< forwards.length; i++) {
>  ActionForward forward = mapping,findForward(forwards[i]);
>  out.print("<A href=\""+forward.getPath()+"\">"+forward.getName()+"</A>";
>}
>
>I know I am lazy, but it works very good except the sorting.  That's why I
>want the elements of the String[] has the order I put in struts-conf.xml
>
>Billy Ng
>

-- 
Eddie Bush




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


Mime
View raw message