Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 615841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:15:47+00:00 2026-05-13T18:15:47+00:00

I am developing a grails application.In that some cases I want to control the

  • 0

I am developing a grails application.In that some cases I want to control the domain class fields based on the role.So that in each call to getter setter method of domain class I want to apply some filter based on role(Logged in user’s role).I am assuming that grails will create getter setter method at runtime for the domin classes.So while writing grails code is it possible to apply this logic.If it is possible then how to apply?

Example:

Domain Class :

class Book{
   String name;
   double price;

  }

Controller:

def index={
  Book book=Book.get(1);
   println book.name;
   println book.price;
 }

In the above code “println book.price;” this line should work only for particular role.For some other role it should throw some exception.

Is it possible achieve?Is there any plugin to do this?

Please give some help on this….Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T18:15:48+00:00Added an answer on May 13, 2026 at 6:15 pm

    You can create get/set methods for the properties you want to control access to and put your security logic there. Assuming you’ve written your own security service or are using a security plugin like the Spring Security (Acegi) plugin you would:

    class Book{
        String name;
        double price;
    
        def authenticateService
    
        void setPrice(double price) {
            if(!authenticateService.ifAllGranted('ROLE_PRICE_FIXER')) {
                throw new Exception("You are not authorized to set book prices")
            }
            this.price = price
        }
    
        double getPrice() {
            if(!authenticateService.ifAllGranted('ROLE_PRICE_FIXER')) {
                throw new Exception("You are not authorized to get book prices")
            }
            return this.price
        }
    }
    

    I am not aware of any plugin that allows access controls to be put on domain properties.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Developing a heavily XML-based Java-application, I recently encountered an interesting problem on Ubuntu Linux.
When developing a new web based application which version of html should you aim
I'm developing a grails plugin that is supposed to be a visual front end
I am developing a grails application which has codenarc plugin. And also I am
iam developing iPhone application that allow user to define stations near to him, so
Hy, I'm developing a Grails app which has to communicate with an existing Java
I am developing a Web Album using Grails and for image processing, I am
Developing a .NET WinForms application: how can I check if the window is in
When developing a desktop application in .NET, is it possible to not require the
I have just started developing a Grails app froma tutorial today, and I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.