struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christian Stone <xt...@stonescape.net>
Subject Feature suggestion for enhancing the struts action configuration.
Date Sun, 11 Apr 2010 20:03:02 GMT
 I was very happy to upgrade my decorators and some of my action results to Freemarker while
using the new sitemesh plugin (being able to mix multiple result handlers such as velocity
and freemarker without having to switch them all over at once).  A huge gotcha I kept running
in to was <result type="velocity">myresultfile.ftl</result>.  Note the Freemarker
file and velocity specification for the result.  I kept running into this while doing search/replace
for certain files and forgetting the type specification while migrating velocity files to
Freemarker.  What do you think about allowing a specification of the result type, but if one
isn't specified it will inspect by extension and map it to a result type for you, defaulting
to a base type if it is unclear.  If you take a page from Ibatis SqlMaps, you could specify...
	<typeAlias extension="vm"  type="velocity" />
	<typeAlias extension="ftl" type="freemarker" /> 
	<typeAlias extension="xhtml" type="freemarker" />      <-- I use this in Idea to
keep from going insane when using Idea+Freemarker.
or
	<typeAlias mapping="*.ftl" type="freemarker" /> 

Then you would not need quite so much configuration in your configuration :)

<action name="index" class="myclass" method="list">
     <result>index.ftl</result>
     <result name="error">myError.vm</result>
     <result name="input">myError.jsp</result>
</action>

or how about defining default elements for all the Action.RESULT_TYPES (success, input, error...)
 Note that you would still use the result element for custom names...

<action name="index" class="myclass" method="list">
     <success>index.ftl</success >
     <error>myError.vm</error>
     <input>myError.jsp</input>
     <result name="myResult">myCustom.ftl</input>
</action>

instead of...

<action name="index" class="myclass" method="list">
     <result type="freemarker">index.ftl</result>
     <result type="velocity" name="error">myError.vm</result>
     <result type="velocity"  name="input">myError.vm</result>
     <result type="freemarker"  name="myResult">myCustom.ftl</input>
</action>

Opinions?  I really believe the configuration is a bit heavy now, and anything that leads
to a reduction of the configuration text is a real boon.

-- Christian Stone
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org


Mime
View raw message