On May 9, 2012, at 3:15 AM, bhushan154 wrote:
> We have a requirement which needs to allow users to subscribe to reports at
> their desired day of week. Say for example I need a report to be mailed to
> me every monday, while another user can choose to have it sent every
> wednesday.
>
> What is the methodology and best approach to implement this solution?
That's a very broad question (and not terribly grails specific). There are a lot of way to do this and the "right way" is going to depend on additional details.
You probably want a User domain object to represent your user. You'll want a property on that object to represent the "notification day". You can do that as a simple property (perhaps a Calendar.DAY_OF_WEEK) or even as a one-to-many association to a "NotificationDay" object.
In either case, creating the CRUD controllers/views is very simple. Indeed, just create the domain object you think you'll want and do a
grails generate-all UserDomainClass
to see an example of a controller and views to handle the crud.
For the mail-sending you can use the quartz/scheduling functionality to kick off code at regularly timed intervals. In that code it's pretty simple to...
// determine the day of the week from the current date
// get all UserDomainClass that have a "notification" setting matching this day
// for each class sending an email
HTH
- Gary
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email