This Question is Possibly Answered

1 "correct" answer available (4 pts) 2 "helpful" answers available (2 pts)
3 Replies Last post: Jul 31, 2008 11:27 PM by Jay Guidos  
madjack Newbie 68 posts since
Sep 8, 2006
Currently Being Moderated

Jul 27, 2008 11:17 PM

Help with Dynamic properties

I made a reference to a nonexistent method in a Groovy class, clicked on the light bulb in the margin to have IDEA create the method for me. I saw an "Add Dynamic Method" entry and tried it out.  What exactly happens when I add a Dynamic Method to the Dynamic properties panel?  Is a method actually created in the class' ExpandoMetaClass?  Also, I couldn't find a way to delete the Dynamic method once added.  How do I do that?  Finally, what artifact(s) gets changed in the project when dynamic methods are added this way?

 

Thanks for helping this old Java guy who's new to Groovy/Grails and JetGroovy.  Thanks for a really helpful plug-in.

 

Jack

Erik Pragt Apprentice 677 posts since
Oct 26, 2004
Currently Being Moderated
Jul 28, 2008 4:26 PM in response to: madjack
Re: Help with Dynamic properties

To answer your questions:

1) no, it's not added to the expandometaclass. The ExpandoMetaClass is a class with which you can change the runtime behaviour of your classes. IntelliJ doesn't use that, but uses an internal reference of methods which IntelliJ can't detect itself, but of which you know the existence. For example: the User.save() method doesn't really exist in the User class, but when you tell IntelliJ Grails added it for you and it returns User instances, it's added to the list of dynamic methods to be used in future code completion.

2) You can remove the methods (which is a bit annoying), by selecting the method in the Dynamic Method panel, and pressing 'delete' on your keyboard.

3) No artifacts get changed. See point 1.

 

Erik

Dmitry Krasilschikov Novice 83 posts since
Jul 14, 2008
Currently Being Moderated
Jul 28, 2008 4:38 PM in response to: madjack
Re: Help with Dynamic properties

When you use "add dynamic method/property" nothing creates in you project source files. It is just utility to you could see methods, which will create on runtime dynamically.

If you know exactly what the name of such method will be and you know parameters as well, you just can add dynamic method to panel to avoid untyped underline and make navigation. These dynamic elements saves in project settings

To delete it press 'delete' button on the panel

To change the name/type click on element on th panel

So, no one aftefact is changed

Jay Guidos Newbie 2 posts since
Jul 31, 2008
Currently Being Moderated
Jul 31, 2008 11:27 PM in response to: madjack
Re: Help with Dynamic properties

Is there any chance of finding some kind of Grails GORM dynamic mappings as predefined in JetGroovy?

More Like This

  • Retrieving data ...