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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:41:54+00:00 2026-05-26T21:41:54+00:00

I am trying to load a value into a field on a view from

  • 0

I am trying to load a value into a field on a view from the action on a controller. How do I reference the specific field I want to load? In .NET it would be something like: in the button click event, this.txtName.Text = “John”. I don’t understand how to do that from a controller and specifically how to reference the view field. I have tried using the params object but it is coming null. I know I am getting to the action based on println statements that I have used.

Here are the relevant code snippets:

from the view:

<td valign="top" class="value ${hasErrors(bean: planetInstance, field: 'name', 'errors')}">
  <g:textField name="name" value="${planetInstance?.name}"/>
</td>
<td class="load">
  <g:actionSubmit value="Load" action="nameLoad"/>
</td>

from the controller:

def nameLoad = {
    // I want to reference and load the "name" textField from the view
}

Any help would be appreciated.

  • 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-26T21:41:54+00:00Added an answer on May 26, 2026 at 9:41 pm

    I cannot tell from your code, but you may have forgotten to map the variable name in your controller action nameLoad:

    class YourController{    
        def nameLoad = {
            def name = Planet.get(params.id).name //This can be whatever you need it to be to get the correct value assigned to the "name" variable.  Here I assume you have a domain class called "Planet" which may or may not be the case.
            return [name:name] //This is where you map key/value pairs.  The name of the key is what you will type to access the value in your view.  The value is the name of the variable you are dealing with, in this case "name".
        }
    }
    

    With the way the code above is set up Grails will assume there is a view called nameLoad in the folder YourController. So the URL will be something like:

    http://localhost:8080/yourapp/yourcontroller/nameload

    In that view you will access name like this:

    ${name}

    Which could be used in any number of tags, like the <g:select> tag for instance:

    <g:select from="${name}" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I'm trying to automatically pass a value from a textbox into a details
When trying to load Microsoft.Xna.Framework.dll from any project, it throws a FileNotFoundException. The specified
I am trying to load Linq on my .Net 3.5 enabled web server by
I am am trying to load a SQL table from a flat file. The
I am trying to load UIImage object from NSData , and the sample code
I'm trying to insert values for a node field from a custom module. The
I am trying to store a null value into the database but everytime I
Im trying to load a csv file into a datatable using oledb. This is
Im trying to load a XML into an object with LinQ in Silverlight with
I am trying to load values into VF input box based on the account

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.