Search code examples
javaspring-roo

Create new page using dynamic finders in Spring Roo


im just learning Roo.

I have a domain object:

Person {
  private String name;
  private boolean graduated;
}

Id like to create a new page that lists only graduated Person objects. Id like this new page to appear on the menu under the List Person's page link.

What is the best practice in Roo to create this new page?

Do I create a new method on the controller?

How do I get the JSP generated?

How do I get this new page to be picked up by the menu.jspx?

Thanks in advance. Georgi


Solution

  • I have created a sample app for you. Download the latest spring roo instalation and run these commands.

    project --topLevelPackage com.stackoverflow.personapp --projectName personapp

    persistence setup --provider HIBERNATE --database HYPERSONIC_IN_MEMORY

    entity --class ~.domain.Person --testAutomatically

    field string --fieldName name --notNull

    field boolean --fieldName graduated --notNull

    controller all --package ~.web

    finder add --class com.stackoverflow.personapp.domain.Person --finderName findPeopleByGraduated

    quit

    Then type mvn clean install jetty:run

    Go to your browser and localhost:8080 you will see the app