I am writing a small webf in Grails and I have the following questions about best practices for controlling design and use of the goram:
/ P>
I am accumulating the user object in the session. Currently all of my action methods start with the following code to ensure that a valid user is logged in and user object is refreshed:
class FooController {def actionMethodThatRequiresAValidUser = {if ( ! Session?. User) {Reader (Controller: "Authentication", Action: "Login"}} session.user.refresh () ... / * Accessories * / ...}}
Is this the best practice? Can it be done in a better and / or more concise manner?
Use this, in this way you place the same repeated code in the filter and your controller has the actual action Keep focused on
Comments
Post a Comment