You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Christian Stone <xt...@stonescape.net> on 2010/04/11 22:03:02 UTC

Feature suggestion for enhancing the struts action configuration.

 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


Re: Feature suggestion for enhancing the struts action configuration.

Posted by David Cloutier <da...@gmail.com>.
I second both notions... anything that keeps the config clear & concise is a +.

Dave

On Mon, Apr 12, 2010 at 2:40 PM, Lukasz Lenart
<lu...@googlemail.com> wrote:
> 2010/4/11 Christian Stone <xt...@stonescape.net>:
>>  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>
>
> It's a brilliant solution in my opinion, please register an issue to
> not forget about that!
>
>> 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.
>
> Hmm... I'm not sure but it also can be a nice future ;-)
>
>
> Regards
> --
> Łukasz
> http://www.lenart.org.pl/
> Kapituła Javarsovia 2010
> http://javarsovia.pl
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
> For additional commands, e-mail: dev-help@struts.apache.org
>
>

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


Re: Feature suggestion for enhancing the struts action configuration.

Posted by Lukasz Lenart <lu...@googlemail.com>.
2010/4/11 Christian Stone <xt...@stonescape.net>:
>  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>

It's a brilliant solution in my opinion, please register an issue to
not forget about that!

> 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.

Hmm... I'm not sure but it also can be a nice future ;-)


Regards
-- 
Łukasz
http://www.lenart.org.pl/
Kapituła Javarsovia 2010
http://javarsovia.pl

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