Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring Roo: Trigger Action on Update – Best Practice
    text
    copied!<p>I have played a bit with <strong>Spring Roo</strong>, now I am asking myself what is the Roo suggested way or best practice way to trigger an action after an object update.</p> <p>Let me explain it with an example: Assume I want to implement a web based Bug Tracker (<em>I don’t want to do this, it is only an example</em>). A bug tracker, is about Issues. Each Issue has a state (New, Confirmed, Assigned, In Progress, Resolved.), a title and some other fields.</p> <p>The user has a web form where it can enter and update all fields (state, title, …). When the state of an issue switches from ‘In Progress’ to ‘Resolved’, the system should send an email to all persons that are interested in the bug (How this list of interested persons is maintained, is out of scope for this problem).</p> <p>The problem that I have is: <strong>How to trigger the email sending process when the state is changed (in a Roo application)?</strong> Because there are several problems:</p> <ul> <li>How to determine if the issue state is changed?</li> <li>We need to make sure, that the message send after the issue is complete updated (for example it would not work, to put the trigger in the setState() method of the Issue, because it is not guaranteed that the other values from the form (title…) are updated before the state is changed.</li> <li>The mail must only be sended if the form was valid and the Issue is likely to be saved (I do not facing the problem that the transaction cannot be committed – this will be another problem)</li> </ul> <p><strong>Does anybody have a good, testable (unit tests) and maintainable solution?</strong> Maintainable means especially that the code to handle this should not be placed in the controller, because it will be used in several controllers and someday somebody will implement an new controller and he will likely forget to handle this email concern. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload