How to implement form builder plugin in grails - grails

What steps will reproduce the problem?
1.create grails project on STS: 2.9.2
2.Open plugin manager, install form builder plugin.
1.Create grails project on NetBeans IDE 7.0
2.Open Grails Plugins. install form builder plugin.
1.Create grails application using command grails create-app test
2.install form builder plugin.
What is the expected output? What do you see instead?
Each time i was expecting plugin should install and i can run application, but getting several dependencies. I tried with/without changes made in BuildConfig.groovy.
What version of the product are you using? On what operating system?
I am working on
Java: 1.6.0_29; Java HotSpot(TM) Client VM 20.4-b02
System: Windows XP version 5.1 running on x86; Cp1252; en_US (nb)
with grails 2.0.4
I have installed STS 2.9.2, STS 2.5.1, Netbeans 7.0 with grails plugin
Please provide any additional information below.
Each time i tried to install plugin it is showing me some run-time dependencies for jquery, jquery ui and others, I tried to install all plugins before installing form builder plugin. Now it is showing me some class missing
net.sf.json-lib:json-lib:2.4.
some time it is showing me error about
C:\Documents and Settings\jitendrakarma.grails\2.0.4\projects\FormTest\plugins\form-builder-0.1\grails-app\controllers\org\grails\formbuilder\FormController.groovy: 18: unable to resolve class freemarker.template.Template
# line 18, column 1.
import freemarker.template.Template
Please let me know what is wrong with the process i am following.

You are doing everything totally right. The plugin itself does not manage its dependencies correctly. Also it is belonging to some classes that doesn't exists any more in Grails >= 2.x.x
If you add all missing external dependencies and add the following entries to the plugin closure of grails-app/conf/BuildConfig.groovy
compile ":form-builder:0.1"
compile ":jquery-ui:1.8.6"
compile ":dynamic-domain-class:0.2.1"
compile ":jquery-json:2.2"
compile ":freemarker-tags:0.5.8"
compile ":uni-form:1.5"
compile ":jquery-datatables:1.7.5"
compile ":jquery-validation-ui:1.2"
compile ":lang-selector:0.3"
compile ":quartz:0.4.2"
compile ":jquery-form-builder:0.1"
and add the following entry to the dependencies section of the same file
compile 'org.freemarker:freemarker:2.3.19'
you will still get four compile errors.
One of them is: "unable to resolve class org.codehaus.groovy.grails.web.metaclass.TagLibDynamicMethods"
If you look up this class in the grails api documentation you will see it inside the grails 1.3.7 version but it is missing in the 2.0.4 version.
So the best thing I could recommend you is to search for another plugin or doing some code by your own.
Validation for example could be done with a Command on the grails side and the JQuery Validation Plugin on the client side. The form itself can be created with the help of scaffolding. Even if you don't need a domain you could create one run scaffolding to get the resulting form and throw away the domain.

Related

NetBeans-11 Can not setup for using Grails

Using NB-8.2 In the dialog - "Tools/Options/Miscellaneous/Groovy" You could enter the location of your Grails-installation" but know with NB11 that input field is missing.
I've read the question "Can not run Grails project from NetBeans" where you where suggested to remove all plugins regarding Gradle and Groovy and then reinstall them, which I tried but it didn't help.
I tried it on NB11.1 and uninstalled the following plugins:
Gradle, Gradle and Groovy and Pure Groovy Project.
Gradle and Grovy including "Gradle and Groovy" couldn't be uninstalled - only deactivated but the last one "Pure Groovy project" could be uninstalled. But afterwards I can not find that plugin to reinstall. So where can I find that?
Now I have installed NB11.2 but still the same problem.
So where to go now?
I got this working on a fresh installation of NetBeans 11.2 under Windows 10 using Grails 3.3.11. However, there are some significant limitations because the approach essentially only recreates the Grails environment that worked with NetBeans 8.2:
Initial Status
There are no Groovy, Grails or Gradle entries on the project wizard menu (File > New Project...).
Tools > Plugins > Installed Plugins shows version 1.38 of Groovy is active, and version 1.2 of Groovy and Gradle is inactive.
The Tools > Options > Miscellaneous > Groovy tab shows that there is no Grails Home field available, as mentioned in the OP.
NetBeans 11.2 Changes
First, note that you must set JDK 1.8 as the default platform for NetBeans 11.2. See this SO answer for details on how to do that. Of course you can still create projects using other JDK versions when the default platform is JDK 8.
Also note that taking the obvious step of activating Groovy and Gradle 1.2 does not help, and subsequently restarting NetBeans does not change anything, so discard that approach.
This is the initial version of the relevant plugins: Gradle 1.2, Groovy and Gradle 1.2 and Groovy 1.38.
Delete all three plugins. Netbeans will restart.
The Groovy tab is now missing from Tools > Options > Miscellaneous.
Select Tools > Plugins > Settings, and click the Add button, which will open the Update Center Customizer screen.
Enter Grails Plugins in the Name field (or any other descriptive value you prefer ), and http://updates.netbeans.org/netbeans/updates/8.2/uc/final/distribution/catalog.xml.gz
in the URL field, and click OK.
Ensure that only the new entry for Grails Plugins is checked on the Settings tab, then go to the Available Plugins tab.
Select the entry for Groovy and Grails 1.34.1, and click Install. NetBeans
will restart.
After NetBeans restarts, select Tools > Options > Miscellaneous and click the Groovy tab. There is now a Grails Home field available, so set it to your Grails installation:
Creating a Grails Project
Select File > New Project > Groovy > Grails Application to create a Grails project.
You will get this error:
Warning |
Unrecognized flag: non-interactive.
Error |
Specify an application name or use --inplace to create an application in the current directory
One workaround for that is to create your Grails project from the command line using grails create-app..., then open that project in NetBeans. See this helpful SO answer for full details.
Once that is done, you can develop, build and run your Grails application in NetBeans 11.2:
Notes
After doing all the steps above, there is no Gradle entry under File > New Project..., and if you attempt to install the Gradle plugin to address that, you will get the following warning:
Don't proceed, because reinstalling Groovy 1.38 (which you deleted in step #6 above) will prevent Grails from working. So be aware that this solution for Grails prevents you from creating freestanding Gradle projects in NetBeans 11.2 using the Project Wizard. Also, to be clear, the only plugin you should have installed to get Grails working is Groovy and Grails version 1.34.1. You do not need any other plugins containing the words "Groovy" or "Gradle" installed.
I also tried creating a Grails project using Grails 4.0.1, but got the error "Could not instantiate global transform class org.spockframework.compiler.SpockTransform...". There are workarounds suggested for that error on SO. I didn't pursue them but since Grails 3.x does not work with any JDK > 8, and Grails 4.x supports JDKs > 8, you may want to pursue this issue yourself.
You can download and install the "Pure Groovy" plugin from here. Although it's old, it still seems to work fine, and it will add a "Groovy Project" entry in the Project Wizard:
Also see does netbeans 11 support grails?, although that question was for NetBeans 11.0 rather than 11.2.

Error creating Grails project in NetBeans

The error I have is the following:
Warning |
Unrecognized flag: non-interactive.
Resolving dependencies..
Error |
Specify an application name or use --inplace to create an application in the current directory
I'm following the steps that come on the NetBeans page.
I have installed:
Grails 3.3.8.
Groovy 2.4.15.
NetBeans 8.2.
From console create a project using grails create-app hello world and in this case it seems that there were no problems.
NetBeans doesn't currently support Grails 3.x as far as I know, however you might be able to import it as a Gradle project. I know that Netbeans is working on updating there Groovy support soon, maybe that will help...
The best IDE for Grails is Intellij Ultimate, which costs money, however you can use the community version, you just won't get GSP support.

Grails GGTS "Task 'assemble' not found in root project" error when running "grails war" in Command Prompt

I have been learning Groovy/Grails Tool Suite (GGTS) 3.6.4, with Grails 2.4.4 using some video tutorials. When I attempt to package the project into an application using the grails war command on the Windows command prompt, I get the following error:
"Error Gradle build terminated with error: Task 'assemble' not found in root project ..."
Any references to this error that I have found online have only involved Android Studio (for instance), so I am at a loss here as to how to fix it for GGTS.
I have Android Studio 1.0.1 installed, and in case it was affecting the Grails packaging, I tried the solution of removing the <component name="FacetManager"> from the general Android Studio "MyApplication.iml" file, but that had no effect. I couldn't find any analogous file for the GGTS.
In case the issue lies elsewhere in my overall installation, I have Java JRE 7_79 (64-bit) installed, as well as the the JDK 1.7.0_79 (64-bit)
OK. I found out what the cause of the error was, and how to avoid it in the future.
The Problem
Grails 3.0.1 requires the following files for grails war to work:
build.gradle
gradle.properties
gradlew
gradlew.bat
\gradle (directory)
Grails 2.4.4 does not require any of the above files for making a WAR file.
GGTS 3.6.4 does not work with Grails 3.0.1, but it comes with and works fine with Grails 2.4.4.
The Solution
Copying the stated Gradle files & directory to a GGTS project folder fixed the problem. However, I wasn't satisfied with needing to do this manually or with a custom batch file for every project.
Looking deeper, it turns out that when working out compatibility issues between the Java 32-bit JRE existing on my system and the Java 64-bit JRE & SDK, Grails, and GGTS versions (there was a lot of fiddling to get things working), at one point I had set up my global variable to Grails to be directed at 3.0.1, and I failed to update it to Grails 2.4.4. Making this change has fixed the issue.
Explaining the Cause
When following this video series on installing a compatible set of Java, Grails, and GGTS, the instructor manually downloaded the latest version of Grails from the Grails site and then downloaded GGTS separately from its own site. Both of these were older versions than what I was working with.
In my case it turns out that, after setting up the Java SDK & Grails, the latest version of GGTS (3.6.4) did not work properly with the latest version of Grails (3.0.1). Fortunately the GGTS bundle came with an older version of Grails (2.4.4), and by referencing that, GGTS would work correctly. However, although I changed the IDE reference to Grails, I forgot to reset my environment variable ...
So GGTS was setting up the project for using Grails 2.4.4. However, when calling grails war, the command was using Grails 3.0.1! Apparently these two versions of Grails use different files for creating a WAR file, so GGTS was not setting up the project directories with the correct local files, and the packaging was failing.
Avoiding Future Occurrences
So, when using GGTS 3.6.4, make sure that all references to Grails point to Grails 2.4.4.
In general, if any GGTS bundle contains a version of Grails, you should have everything set up to use that version, even if it is old.

Grails, GGTS Setup

I need to setup a Windows working environment for Grails. I'd like to use GGTS as an IDE but got several errors compiling a sample project. Currently I'm using jdk1.8.0_40 and Grails 2.5.0. which results in this error (but in the end the project is working):
Groovy:Unexpected problem with AST transform: The Spock compiler
plugin cannot execute because Spock 1.0.0-groovy-2.4 is not compatible
with Groovy 2.3.10. For more information, see http://versioninfo.spockframework.org
On top of that there are two Java Exception Breakpoints which are listed as "unknown". Only info regarding version support I could find is:
Java SDK 1.5+ for Grails 1.2 or greater
GGTS itself seems not to run with the latest grails (3.0.1) since I simply cannot add it (directory appears not to be a grails installation).
Should I use Java 7 instead?
This issue is not related to JDK 1.8 or 1.7, but its is related to the GGTS IDE 3.6.4 Groovy Compiler version. As the error clarifies that Spock 1.0.0 version needs Groovy 2.4 compiler.
GGTS 3.6.4.RELEASE-e4.4.2 IDE comes with Groovy 2.3.10 compiler by Default.
Install Groovy Compiler 2.4 Feature and "switch to 2.4" will resolve this issue.
Refer: http://docs.codehaus.org/display/GROOVY/Compiler+Switching+within+Groovy-Eclipse
If you cannot switch compilers from the IDE Groovy Compiler preference page, follow the instructions to perform the switch from outside of Eclipse:
(Grails 2.5.0 uses Spock 1.0.0 (and internally Groovy 2.4.3 and this is why your project is compiling & working fine as the Grails runtime environment is taking over)
As an additional experience report to the answer above, thus providing another solution variant: I had to use the http://dist.springsource.org/snapshot/GRECLIPSE/e4.4 update site (as opposed to the release version mentioned in the link above) to make the 2.4 compiler feature available in the update manager.
After installation, the compiler errors are gone.
I noticed that project-specific groovy compiler is set in the Groovy Compiler preference page in new grails projects. By selecting "I don't care" for "Groovy compiler" it will default to the workspace groovy compiler which is usually correct (for me it's version 2.4). This worked for me but experience may vary.

Can't compile grails Tomcat plugin

I'm using Netbeans to build a Grails app, while I have used this fine before on this new computer I can not get even the basic project to compile and run. I am getting errors around compiling the Tomcat plugin. If I uninstall the plugin it and use Jetty instead it will compile but the project isn't set up for Jetty and is missing files.
Below is the error I'm getting I'm thinking it is some issue with my classpath but I just don't know where to start any help would be much appreciated.
java.lang.NoClassDefFoundError: org/apache/catalina/startup/Tomcat$ExistingStandardWrapper
Update I have tried grails clean, and used both grails 1.2.0 and 1.3.1
Update The project I've tried with tomcat is the base project generated by grails.
When you say "but the project isn't set up for Jetty and is missing files." what do you have in there that maybe clashing with Tomcat? It sounds like you must be using some specific tomcat functionality.

Resources