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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:06:30+00:00 2026-06-16T11:06:30+00:00

Can anyone help me how to use the grails tags like g:select,g:label while creating

  • 0

Can anyone help me how to use the grails tags like g:select,g:label while creating a taglib functionality.

Following is my code.

I have create a taglib functionality

 def dynamicAdvancedSearchTagLib={attrs, body ->
    String beanName = attrs.remove("beanName")
    def bean = request.getAttribute(beanName)
    out << createAdvancedSearchUI(bean)

}
def createAdvancedSearchUI(bean){
    StringBuilder sb = new StringBuilder();

    sb<<"""<fieldset class="search-advanced collapsed"style="border: 1px solid #CCC;padding:0px 21px 0px 21px;border-radius:8px 8px 8px 8px;min-height:24px;">
    <legend>
        <span id="advancedsearch"> <label for="advancedsearch">Advanced Search
        </label>
        </span>
    </legend>
    <g:form method="post">
    <div id="searchcontent">
        <div class="advanced-content-search">
            <label for="Criteria Name">Criteria Name <span
                class="required-indicator">*</span>
            </label>
            <select id="searchCriteria" name="searchCriteria" required="">
            *****<option value="0" selected="selected">Choose...</option>
            <option value="1">Something</option>
            <option value="2">Something else</option>
            <option value="3">Another choice</option>**
            </select>***
        </div>
        <div style="margin-left: 338px;">
            <label for="Enter Your Search Here"> Enter Your Search Here <span
                class="required-indicator">*</span>
            </label>
            <input type="text" name="advancedSearchText"
                value="" required="" />
        </div>

    </div>
    </g:form>
</fieldset>"""
}

Here my requirement instead of using the select html tag i need to use the g:select.

I have a static gsp page i have used g:select as

    <g:select id="searchCriteria" name="searchCriteria"
                        from="${SearchCriteria?.values()}"  value="${searchInstance.searchCriteria}"
                        noSelection="${['':'---Select any One---']}" required="" />

The same functionality should has to be used while creating the taglib functionality..

If anyone knows how to use the grails tags while createing taglib, please help me.

  • 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-16T11:06:35+00:00Added an answer on June 16, 2026 at 11:06 am

    You need to use something like this

    def attrs=["id":"searchCriteria","name":"searchCriteria"]//fill other values
    def formTagLib = grailsApplication.mainContext.getBean('org.codehaus.groovy.grails.plugins.web.taglib.FormTagLib')
    formTagLib.select.call(attrs)
    

    Here is a tutorial for the above that I found in Overwrite and reuse section

    As an alternative you can also use

    out << g.select(attrs) 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can anyone help me on how to convert the following c# code to use
Can anyone help me to rewrite the below code which use a fade effect
can anyone help me use the jquery ui selectable library to perform the following
Can anyone help me decipher why the following code only works on the first
I'm using this PHP framework for use with Shopify's API Can anyone help me
Can anyone help me in converting scalar type of openCV to basic types like
Can anyone help on how to use the matrix scaletype to zoom an imageview
Can anyone help with a jQuery snippet that would use Ajax to pull an
Can anyone help me. I don't use Client-side Javascript often with HTML. I would
Can anyone help me understand when to use :NEW and :OLD in PLSQL blocks,

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.