[ http://issues.apache.org/struts/browse/WW-1420?page=comments#action_38209 
] 
            
Ted Husted commented on WW-1420:
--------------------------------

If you look at *any* given struts-config or strus.xml, the fact you will see 
repeated over and over and over again is the Action class.  Sure, if you 
refactor in anger for wildcards, you may be able to factor out the class most 
of the time, but having tried it more than once, I can tell you it's a 
challenge.  

Here's another example from the MailReader: 

---

    <package name="subscription" namespace="/" extends="mailreader-support">

        <global-results>
            <result name="input">/Subscription.jsp</result>
            <result type="redirect-action">Registration!input</result>
        </global-results>

        <action name="Subscription!save" method="save" 
class="mailreader2.Subscription">
            <interceptor-ref name="user-submit" />
        </action>

        <action name="Subscription!*" method="{1}" 
class="mailreader2.Subscription" />

    </package>

---

If we try to map something like *!* , it's going to match other classes too. I 
don't want to match other classes, because some of the results follow a 
different pattern. The next alternative would be to put each class in its own 
namespace, but then all the URIs will change, and there will more configuration 
than being able to just specify the class as needed.

Whenever someone talks about making development simplier, nine times out of 
ten, they are talking about *normalizing* development. It's all about how can 
we stop repeating ourselves. How can we embed a single fact in an application 
once? How can change a fact without editing four files in three folders? That's 
what convention over configuration is about: Saying it once.

If someone wants to refactor the mailreader so that we don't repeat the 
classname or any other fact, please do. I'd truly like to see how we can do 
that. But in the end, I think the simplest solution would be to provide a way 
to declare a default Action class for a package. AFAIK, it's the one default we 
cannot declare. Why make an exception? 



> default-class-ref
> -----------------
>
>                 Key: WW-1420
>                 URL: http://issues.apache.org/struts/browse/WW-1420
>             Project: Struts 2
>          Issue Type: Improvement
>    Affects Versions: 2.0.1
>            Reporter: Ted Husted
>
> Allow a package to specify a default Action class. 
> <package name="country" extends="orgListers, crud" namespace="/country">
>     <global-results>
>         <result name="CRUD-list" 
> type="freemarker">/template/eplus/metaDataList.ftl</result>
>     </global-results>
>     <default-interceptor-ref>crudStack</default-interceptor-ref>
>     
> <default-class-ref>com.eplus.app.country.action.CountryCrudAction</default-class-ref>
>     <action name="*Country" method="{1}">
>         <interceptor-ref name="{1}Stack"/>
>     </action>
>     <action name="saveCountry" method="save"/>
>     <action name="deleteCountry" method="delete"/>
> </package>

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://issues.apache.org/struts/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to