-2

I'm new to grails and I would like to know how to get all the properties of a login user in an application. I've used MYSQL db to store its information such as username, passowrd, address, etc. I would like to know how to get the specific value of its properties from the database and display it on a textfield/gsp. Please help. tnx..

  • 1
    You really shouldn't be doing it this way... Please look into the security plugins for Grails, such as the core security plugin... – tim_yates Jul 29 '12 at 17:39

1 Answers1

0

If you'd like to fetch list of user object with pagination, you can use:

def users = User.list(params)

where params is map (hash) of request (CGI) parameters. params should contains offset and max.

If you'd like to fetch user by id:

def users = User.get(<ID>)

or

def user = User.findById(<ID>)

Or by some other property:

def user = User.findBy<PROPERTY_NAME>(<PROPERTY_VALUE>)

Each of these method should return user object with all fields. In gsp, we can display it as:

${user?.username}

or

${fieldValue(bean: user, field: "username")}
Andriy Budzinskyy
  • 1,971
  • 22
  • 28