struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <Craig.McClana...@eng.sun.com>
Subject Re: action.xml attribute v elements, & specifying style
Date Tue, 20 Jun 2000 22:20:36 GMT
Hi Craig ... cool name by the way :-)

Craig Randall wrote:

> Hi, I'm fairly new to this list. Struts looks quite useful! I do have a
> couple of questions about the framework:
>
> 1. In action.xml is there a technical reason why attributes are used so
> heavily and not elements? Since the values of the current attributes may be
> quite diverse, it seems to me that elements might be a bit more appropriate,
> and in the long-run, more flexible.
>

The syntax being used grows out of a pattern popularized in the Ant and Tomcat
tools for configuring complex sets of Java objects.  Boiled down to a nutshell,
this style tends to use an XML element to represent a Java object, and XML
attributes to represent the properties of that object, with one-to-many
relationships between objects represented by element nesting.   For the
attributes==properties scenario, Struts includes a capability (in the Digester
package) to match up attributes to the corresponding property names, without
having to be explicit about which ones you are updating, and set them all in one
fell swoop.  In Struts, one of the things this style lets you do is extend the
ActionMapping interface (or subclass the ActionForward class) and add some new
properties -- and the configuration setup will set all the new properties for
you with *no* changes to the code itself.  It's all done by reflection and name
matching.

One of the downsides to this approach is that you cannot specify a DTD for the
action.xml file -- because there is no fixed set of attributes that are legal.
This doesn't stop you from building an application-specific DTD for your own
scenario, though.

> 2. Has any thought been given toward augmenting Struts to specify style
> (e.g. CSS) so that all forms, etc. have a consistent look-and-feel that's
> easy to change via XML?
>

Recently, an optional "style" attribute was added to all of the relevant Struts
custom tags, so that you can specify your own style attributes.  In addition,
the optional "styleClass" attribute generates a "class=" reference to an
internal or external stylesheet.

>
> Thanks.

> -Craig Randall (csrandall@hotmail.com)
>

Craig McClanahan



Mime
View raw message