Win a copy of Real-World Software Development: A Project-Driven Guide to Fundamentals in Java this week in the Agile and Other Processes forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

[Grails] Add form elements with javascript

 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everybody !

I'm new with Grails and I'm trying to add a field in a form. You'll see in the code below that I want to add a select field. However I don't succeed doing this. By despair I've tried doing this in plain javascript, but once again it didn't work (I can't even add a textfield !).
I've been consulting grails doc, but I've not found my answer. So do you have an idea how to do this ?

Here is my actual code (I've let js but I would rather do this in full Grails) :

addCompetences.gsp :




ProfilController.groovy (very *empty* for the moment, and wrong for the moment)



Thank you in advance.
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


You haven't specified the container that should hold the rendered HTML coming back from the server. Look at the update attribute:

http://www.grails.org/doc/latest/ref/Tags/remoteFunction.html
 
Jack Rackham
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had tried with update, but Grails didn't like (not with the same as in the example ; and I've just tried now, It makes the same error). Look by yourself :

Error 500: Could not parse script [home_xavier_Projets_package_grails_app_views_profil_addCompetences_gsp]: startup failed: home_xavier_Projets_package_grails_app_views_profil_addCompetences_gsp: 69: expecting ')', found 'update' @ line 69, column 21. update:'div' ^ 1 error
Servlet: grails
URI: /package/grails/profil/addCompetences.dispatch
Exception Message: startup failed: home_xavier_Projets_package_grails_app_views_profil_addCompetences_gsp: 69: expecting ')', found 'update' @ line 69, column 21. update:'div' ^ 1 error
Caused by: Could not parse script [home_xavier_Projets_package_grails_app_views_profil_addCompetences_gsp]: startup failed: home_xavier_Projets_package_grails_app_views_profil_addCompetences_gsp: 69: expecting ')', found 'update' @ line 69, column 21. update:'div' ^ 1 error
Class: home_xavier_Projets_package_grails_app_views_profil_addCompetences_gsp
At Line: [86]



I've changed the structure of the page between times, but I had exactly the same error. In update, i've tried to put first the type of the container, the id of the element, and what is said as in example. Same error everytime.

So I've tried another way, more "conventionnal", but I still got an error. My js code is implemented, however it's not recognized ! Filezilla says that any method I try to call doesn't exist. I've done it with pure JS and jQuery, but anything I do, nothing happens. Even an alert with jQuery.

 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


You're missing a comma after the action.
 
Jack Rackham
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your answer. I fixed this silly mistake but I still add an error. Finally a friend of mine did it by another way.
 
If you live in a cold climate and on the grid, incandescent light can use less energy than LED. Tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!