Is it possible to combine dynamic Javascript menu systems with Struts?
Created May 7, 2012
Ted Husted The challenge with doing this is that the JSP tags run on the server (as the page is being generated), while the JavaScript
runs on the client side. To integrate the two, you need your tags (and other JSP code) to dynamically generate the JavaScript
functions themselves -- sort of having a program write a program -- so that the JavaScript is customized to your particular need on
this particular page. A very trivial example is the way that the <html:form> tag deals with the "focus" attribute. If you specify
it, a dynamically generated bit of JavaScript is created to set the input focus, which includes the name of the field you want
initial focus assigned to. For a more comprehensive scenario, consider that for most menuing systems you will need to configure the
list of available options into a JavaScript array or something. You could use the <logic:iterate> tag to render the elements that
get set in the array's initialization expression.