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

  • Home
  • SEARCH
  • 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 8201931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:59:11+00:00 2026-06-07T06:59:11+00:00

I have a grails app using persistence annotated POJOs for domain model. Grails generates

  • 0

I have a grails app using persistence annotated POJOs for domain model. Grails generates controllers and views from them as expected, but one class is a puzzle for me.

I need to represent a collection of strings ( at the moment an ArrayList of strings ) in that is grails-view ‘friendly’ and will render as a drop-down.

The data in ArrayList is ‘fairly’ constant so I thought enum could be used for it, but I’m just not sure.

The class in question:

/**
 *  available categories:
 *      Airplane
 *      Rotorcraft
 *      Glider
 *      Lighter than air
 *      Powered lift
 *      Powered parachute
 *      Weight-shift-control
 */
@Entity
public class AircraftCategory {

    public AircraftCategory(){

    this.aircraftCategories.add("Airplane");
    this.aircraftCategories.add("Rotorcraft");
    this.aircraftCategories.add("Glider");
    this.aircraftCategories.add("Lighter Than Air");
    this.aircraftCategories.add("Powered Lift");
    this.aircraftCategories.add("Powered Parachute");
    this.aircraftCategories.add("Weight Shift Control");   
    }

    long id;
    private long version;   
    private ArrayList <String> aircraftCategories = new ArrayList<String>();

    public ArrayList <String> getAircraftCategories() {
        return aircraftCategories;
    }

    public void setAircraftCategories(ArrayList <String> aircraftCategories) {
        this.aircraftCategories = aircraftCategories;

    }

    @Id
    @GeneratedValue
    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }    

    public long getVersion() {
        return version;
    }

    public void setVersion(long version) {
        this.version = version;
    } 
}
  • 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-06-07T06:59:13+00:00Added an answer on June 7, 2026 at 6:59 am

    The easiest thing to do is to push this into the DB as a “proper” domain object. It’s a bit silly to have an object that is essentially just a name field, but it will render as you want it to in the scaffolded views (assuming you have the association to your actual object).

    The other advantage is that you have an easy extension point in your application later in case you need to add more data to AircraftCategory, like abbreviation for example.

    For another possible solution, this question is very similar.

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

Sidebar

Related Questions

I have this domain model, grails-app/domain , named com.portal.Schedule.groovy having this properties: Subject subject
I have a Grails app that loads its data from xml files and delivers
I have upgraded my grails app from 1.3.7 to 2.0.1. I had few static
I'm developing a Grails App. I have about 20 Controllers right now and there
I have a Grails 2.0.0 project that was created using grails create-app . In
We're developing an app (using Grails Spring Security (formerly Acegi)) in which we'll have
Background: we have a Grails 1.3.7 app and are using Liquibase to manage our
All, I am trying to test my grails app using Hudson. I have in
We're using Grails but with an existing model layer and DAO layer. We have
I have a grails app, and I am using the java-apns 0.1.5 jar! I

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.