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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:24:24+00:00 2026-05-22T03:24:24+00:00

I have the folowing gsp page: <g:form controller=?? action=??> <h1>Search</h1> <g:submitButton name=search value=Search/> <div

  • 0

I have the folowing gsp page:

 <g:form controller="??" action="??">
    <h1>Search</h1>
    <g:submitButton name="search" value="Search"/>

    <div id="resultsHere">

    </div>

    </g:form>

What i want to do is, everytime “Search is clicked”, the database is searched for that record, lets imagine im looking for book titles. So everytime i write a title, the database finds the books and print every data related to the books. How can i do that=?

My idea is having something similar to this in the div:

<ul>
<g:each in="${bookList}">
  <li>Name: ${it.name}, Locale: ${it.isbn}</li>
</g:each>
</ul>

So the point is, when the search button is clicked, the controller that handle that action should redirect the page to the same page, and pass the filtered list of books so it can be printed in the <g:each in="${bookList}"> tag.

I would like opinions about this being the best solution in this case. I could also render the results in the page directly, but i would like to do some css for the lookings so i think that wont be a good idea using render. Any help would be apreciated, and if possible, some lights with the code (specially the filtering part).

  • 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-22T03:24:25+00:00Added an answer on May 22, 2026 at 3:24 am

    I would have one action in your controller, and render out the list.

    ie: as pseudo-code (and not complete)

    BookController {
      def search = {SearchComamnd search ->
    
        def books = []
        if(search) {
          books = Book.createCritera().list {
            and { 
              title(search.title)
              author(search.title)
            }
          }
        }
    
        render [ books:books ]
      }
    
      class SearchCommand {
        def author
        def title
      }
    }
    

    and then when in your view

    <g:form controller="??" action="??">
        <h1>Search</h1>
        <g:submitButton name="search" value="Search"/>
    
    </g:form>
    <g:each in="${books}">
      <li class="book">Name: ${it.name}, Locale: ${it.isbn}</li>
    </g:each>
    

    you can now use css li.book to decorate the entry.

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

Sidebar

Related Questions

I have the following gsp page: <g:def var=incidentMngmntId value=${incidentMngmntInstance?.id}/> <g:link controller=ticketMngmnt action=list params=[incidentMngmntId :
Hi I have the following code in my grails gsp <form action=upload-script-url method=post enctype=multipart/form-data>
Please help. I have page login/auth.gsp with the following code inside the body <div
I have the folowing inptuts! <input type=checkbox value=1 /> <input type=checkbox value=2 /> <input
I have the folowing situation. I want to retrieve a list of bids between
I have the folowing table: Case with columns > ID,ResponsibleID Action with columns >
I have the folowing tables: Table student: id name 1 foo 2 bar 3
I have a modal dialog where I load a form from a gsp and
I have the following g:render tag in a gsp page: <g:render template=/artist/rate model='[artistID: 1,
I have de folowing classes : [DataContract] public class MyProject { [DataMember(Name = Branches)]

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.