Jason Carreira wrote:
Could you give an example how multiple mappings for a
single action is
used with common CRUD actions?
Don
Ok, here's what our Invoice CRUD action mappings look like:
<action name="listInvoice" class="com.eplus.app.invoice.action.InvoiceCrudAction"
method="list">
<interceptor-ref name="listStack"/>
<result name="CRUD-list" type="freemarker">/template/eplus/metaDataList.ftl</result>
</action>
<action name="editInvoice"
class="com.eplus.app.invoice.action.InvoiceCrudAction">
<interceptor-ref name="editStack"/>
</action>
<action name="saveInvoice" class="com.eplus.app.invoice.action.InvoiceCrudAction"
method="save">
<interceptor-ref name="crudStack"/>
</action>
<action name="deleteInvoice" class="com.eplus.app.invoice.action.InvoiceCrudAction"
method="delete">
<interceptor-ref name="crudStack"/>
</action>
For this case, I would rather construct a single interceptor stack that
could handle all requests so I could do:
<action name="invoice/*"
class="com.eplus.app.invoice.action.InvoiceCrudAction" method="{1}">
<result name="list"
type="freemarker">/template/eplus/metaDataList.ftl</result>
...
</action>
This also has the advantage of having cleaner URL's, IMO. Furthermore,
you could use "*/*" and match all your crud actions in one shot.
A better example of reusing the same action with the same method several times is our DomainObjectLister. We're still working out the entity meta-data we've been building, so I foresee this continuing to evolve, but it's pretty simple already. In the future you'll just need to configure it with the domain type.
<action name="getVendorRelationships"
class="com.eplus.lib.web.action.DomainObjectLister">
<param
name="domainClass">com.eplus.biz.catalog.mgmt.model.VendorRelationship</param>
<param name="visibleFields">vendor.name</param>
<param name="idField">id</param>
<param name="sortColumn">vendor.name</param>
<result name="success"
type="freemarker">/template/eplus/lists/domainObjectTable.ftl</result>
</action>
<action name="getBuyerCatalogs" class="com.eplus.lib.web.action.DomainObjectLister">
<param
name="domainClass">com.eplus.biz.catalog.mgmt.model.BuyerCatalog</param>
<param name="visibleFields">name,description</param>
<param name="idField">id</param>
<param name="sortColumn">name</param>
<result name="success"
type="freemarker">/template/eplus/lists/domainObjectTable.ftl</result>
</action>
In this case, you would definitely want to use the XML configuration
option. One you start creating generic, parameterized Actions, the XML
plays a much larger part in the process. However, I'm not sure those
still wouldn't be the edge cases.
Don
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.opensymphony.com/thread.jspa?threadID=38338&messageID=75787#75787
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]