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 7723943
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:34:15+00:00 2026-06-01T04:34:15+00:00

I have an object (Manager) with a list of another object (ActionItems) . With

  • 0

I have an object (Manager) with a list of another object (ActionItems). With both these objects I am using the CRUD module from which I override the Managers/show.html but I want to show all the action Items belong to a Manager on the same page. The ActionItems should only be available by selecting the manager object. How do I go about this?

public class Manager extends Model{
   ...
   public List<ActionItem> actions;
   ...
}

public class ActionItem extends Model{
 ...
}

public class Managers extends CRUD{

}
  • 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-01T04:34:16+00:00Added an answer on June 1, 2026 at 4:34 am

    There is no simple way to do this. More customization – more code.

    Managers/show.html

    #{extends 'CRUD/layout.html' /}
    #{set title:messages.get('crud.show.title', type.modelName) /}
    
    <div id="crudShow" class="${type.name}">
    
      <h2 id="crudShowTitle">&{'crud.show.title', type.modelName}</h2>
    
      <div class="objectForm">
      #{form action:@save(object._key()), enctype:'multipart/form-data'}
    
        *{
        * You must hide default output of the crud.form for the "actions" field.
        * Just specify all fields of the Manager except the "actions".
       }*
    
        #{crud.form fields:['someField1', 'someField2', 'someField4'] /}
    
        *{
        * Now you can draw some list that contains all manager`s actions.
       }*
    
        <ul>
          #{list items:'object.actions', as:'action'}
           <li>
            <a href="@{Actions.show(action.id)}">${action}</a>
           </li>
          #{/list}
        </ul>
    
        *{
        * For adding a new action you need a something like link below.
        * There we try to retieve Manager`s id in the Action`s blank
        * method. Than we could try to modify blank() and intercept id for
        * our purposes.
       }*
        <a href="@{Actions.blank(object.id)}">Add new action</a>
    
        <p class="crudButtons">
          <input type="submit" name="_save" value="&{'crud.save', type.modelName}" />
          <input type="submit" name="_saveAndContinue" value="&{'crud.saveAndContinue', type.modelName}" />
        </p>
      #{/form}
      </div>
    
      #{form @delete(object._key())}
        <p class="crudDelete">
          <input type="submit" value="&{'crud.delete', type.modelName}" />
        </p>
      #{/form}
    
    </div>
    

    Actions.java

    public class Actions extends CRUD {
    
        // ...
    
        /** 
         * Modifed blank() method, that will retieve managerId to
         * Actions/blank.html, that will retieve it into modifed create()
         * method.
         */
        public static void blank(Long managerId) throws Exception {
            ObjectType type = ObjectType.get(getControllerClass());
            notFoundIfNull(type);
            Constructor<?> constructor = type.entityClass.getDeclaredConstructor();
            constructor.setAccessible(true);
            Model object = (Model) constructor.newInstance();
            try {
                render(type, object, managerId);
            } catch (TemplateNotFoundException e) {
                render("CRUD/blank.html", type, object, managerId);
            }
        }
    
        /** 
         * Modifed create() method.
         */
        public static void create(Long managerId) throws Exception {
            ObjectType type = ObjectType.get(getControllerClass());
            notFoundIfNull(type);
            Constructor<?> constructor = type.entityClass.getDeclaredConstructor();
            constructor.setAccessible(true);
            Model object = (Model) constructor.newInstance();
            Binder.bindBean(params.getRootParamNode(), "object", object);
            validation.valid(object);
            if (validation.hasErrors()) {
                renderArgs.put("error", play.i18n.Messages.get("crud.hasErrors"));
                try {
                    render(request.controller.replace(".", "/") + "/blank.html", type, object);
                } catch (TemplateNotFoundException e) {
                    render("CRUD/blank.html", type, object);
                }
            }
            object._save();
    
            /* Custom part {{{ */
            Manager manager = Manager.findById(managerId);
            manager.actions.add(object);
    
            flash.success(play.i18n.Messages.get("crud.created", type.modelName));
            if (params.get("_save") != null) {
                Managers.show(managerId);
            }
            if (params.get("_saveAndAddAnother") != null) {
                Actions.blank(managerId);
            }
            Actions.show(object._key(), managerId);
            /* }}} */
        }
    
        /** 
         * Modifed show() method.
         */
        public static void show(String id, managerId) throws Exception {
            // ...
        }
    
        // Other modifed methods... if need.
    
        // ...
    
    }
    

    Actions/blank.html

    #{extends 'CRUD/layout.html' /}
    #{set title:messages.get('crud.blank.title', type.modelName) /}
    
    <div id="crudBlank" class="${type.name}">
    
        <h2 id="crudBlankTitle">&{'crud.blank.title', type.modelName}</h2>
    
        <div class="objectForm">
    
        *{
        * Here we retieve managerId to modifed Actions.create().
       }*
    
        #{form action:@create(managerId), enctype:'multipart/form-data'}
            #{crud.form /}
            <p class="crudButtons">
                <input type="submit" name="_save" value="&{'crud.save', type.modelName}" />
                <input type="submit" name="_saveAndContinue" value="&{'crud.saveAndContinue', type.modelName}" />
                <input type="submit" name="_saveAndAddAnother" value="&{'crud.saveAndAddAnother', type.modelName}" />
            </p>
        #{/form}
        </div>
    
    </div>
    

    Something like this I did at your place.

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

Sidebar

Related Questions

I have a manager class maintaining a list of objects. Each Object has a
I have a tree-like object, managed by Hibernate. The object has a list of
I have a list of objects in a UITableView , managed by a NSFetchedResultsController
I have a managed object which acts as a playlist, it has a to-many
I have class World which manages creation of object... After creation it calls afterCreation
I have a fairly involved managed data model which has a central object with
So I have the standard C++ setup with an object that stores another object.
I have a CoreData model with 2 objects. The first object (Images) contains a
I have a foreach that displays all the thumbnail images from a list of
I have a listbox which is databound to a collection of objects. I want

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.