Hi all,

Just trying to give back (or a shameless plug - you decide)
Months ago (last year really) I implemented a regular expression
action mapper similar to Django's URL dispatcher.

Given this regex.mapping file

listProduct::^/products$
showProduct:entityId:^/product/([0-9]+)$
showProduct:productName:^/product/([a-zA-Z0-9_]+)$
deleteAttributeProductAdmin:entityId,entityType,attributeId:^/admin/product/([0-9]+)/delete/(type|colour|size)/([0-9]+)$

Given a URL the regex action mapper will search through its list (in
order) for a match (the patterns are compiled so it's fast).

Therefore

/pepperviolet/products will invoke the listProduct action
/pepperviolet/product/89 will assign 89 to the variable entityId and
call showProduct
/pepperviolet/product/Sony_Bravia will assign "Sony_Bravia" to
productName and call showProduct
/pepperviolet/admin/product/999/delete/type/77 will do entityId = 999,
entityType = "type" and attributeId = 77 and call
deleteAttributeProductAdmin

It is hosted at http://code.google.com/p/pepperviolet/
I'm not sure what's the state of RESTful style mapping in Struts2 now,
but if just 1 person finds this useful I'm happy already.
Feedback is greatly appreciated.

Thanks.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to