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
LeftMenu




JSPWiki v2.2.33

[RSS]


Hide Menu

StrutsMenu


Difference between version 34 and version 3:

At line 3 changed 1 line.
Refactorings:
!!Refactorings
At line 10 changed 1 line.
In this example, the variable 'test' is searched for using pageContext.findAttribute("test"). You could easily set this parameter using JSTL and <c:set var="test" value="value" />. It probably wouldn't be too hard to add support for request parameters too.
In this example, the variable 'test' is searched for using pageContext.findAttribute("test"). You could easily set this parameter using JSTL and <c:set var="test" value="value" />. I also added support for request parameters if not found in the pageContext.
At line 12 changed 1 line.
{{{
[{Java2HtmlPlugin
At line 39 changed 2 lines.
context.put("displayer", this);
}}}
context.put("displayer", this);
}]
At line 53 changed 1 line.
__#local ($menu $level)__
#local ($menu $level)
At line 59 changed 1 line.
__#end__
#end
At line 69 changed 1 line.
  
  
At line 94 changed 1 line.
----
!!Issues
* I don't know if its Velocity or the tag library, but someone is caching the templates and the only way to get them to refresh is to restart Tomcat. I'd like to be messing with the JSP and it's template on Tomcat and just refresh them in the browser (after saving). It'd sure cut down on development time. ''Lance: This probably is Velocity, have you checked your velocity properties to make sure cache=false? And try adding this: velocimacro.library.autoreload=true''. ''Ivan: I recently found out that Tomcat 4.1.29 (and probably others) caches the content of resources loaded through getResourceAsStream() (very confusing), this may be causing your problems. As a work around my reloadable configuration class was changed to simply getResource() and then opening the stream on the URL.''
* There seems to be an issue when you have two menus (menu:useMenuDisplayer tag) on one page. The second menu seems to try and use parts of the first table's config. Wierd. ''Lance: I've seen some scope issues like this on Roller. There are some optional flags documented in the Users Guide that may help with this - though it isn't altogether clear which does what.''
At line 96 changed 1 line.
TODOs:
__UPDATE:__ I solved all of these issues by implementing Velocity's WebappLoader rather than the one from Roller. Here's the code I used to initialize it:
At line 102 added 50 lines.
[{Java2HtmlPlugin
/**
* Key used to access the ServletContext in the Velocity application attributes.
*/
public static final String SERVLET_CONTEXT_KEY = ServletContext.class.getName();
//~ Methods ================================================================
public void init(PageContext pageContext, MenuDisplayerMapping mapping) {
super.init(pageContext, mapping);
this.pageContext = pageContext;
// MR: Copied from VelocityViewServlet to initialize WebappLoader
Velocity.setApplicationAttribute(SERVLET_CONTEXT_KEY,
pageContext.getServletContext());
// default to servletlogger, which logs to the servlet engines log
Velocity.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS,
ServletLogger.class.getName());
// by default, load resources with webapp resource loader
Velocity.setProperty(RuntimeConstants.RESOURCE_LOADER, "webapp");
Velocity.setProperty("webapp.resource.loader.class",
WebappLoader.class.getName());
// now all is ready - init Velocity
try {
ResourceBundle rb = ResourceBundle.getBundle("velocity");
Properties props = new Properties();
for (Enumeration keys = rb.getKeys();keys.hasMoreElements();) {
String key = (String) keys.nextElement();
props.put(key, rb.getString(key));
}
// only initialized the first time it's called, from:
// http://jakarta.apache.org/velocity/developer-guide.html
// it's ignored for subsequent calls
Velocity.init(props);
} catch (Exception e) {
log.error("Error initializing Velocity: " + e.getMessage());
e.printStackTrace();
}
}
}]
!!TODO
At line 99 removed 3 lines.
* Currently, to do recursion in Velocity templates, I had to use a #local declaration which is in the "whiteboard" directory of Velocities CVS. See velocity's mailing list for [more information|http://www.mail-archive.com/[email protected]/msg09091.html].
* Improve documentation and examples in Maven docs.
* Edit Maven files to generate distribution files.
At line 156 added 3 lines.
__Update:__ [I|MattRaible] just thought of something that would be pretty cool. Allow the name in <menu:displayMenu name="indexMenu"/> to refer to the name of a tiles definition that defines a menu. That'd be slick!

Back to StrutsMenu, or to the Page History.