Grails Cookbook - A collection of tutorials and examples

Grails 3 Vue.js AJAX Table Examples

With all the popular JavaScript framework, I believe that Vue.js stands out as a powerful yet easy to learn framework. Other popular JavaScript framework have high learning curve. It takes weeks to understand and write simple stuff. Vue.js is a breath of fresh air because it provides excellent features yet it can be learned within minutes. In fact, I have written the example in this tutorial in less than 1 hour and having no prior Vue.js background. Here is an example on how to write in Grails 3 and Vue.js an AJAX table that displays records of a database table in paginated form.

Grails 3 Vue.js Hello World Examples

The release of Grails 3 coincide with the growing popularity of more modern Javascript frameworks. Gone are the days where we mostly write code in gsp and jQuery. Frameworks like AngularJS, React, Ember and others are gaining popularity. For beginners, I highly recommend Vue.js because it is very easy to learn like Grails. A developer with some experience will be able to grasps how to use it in minutes. But as always, the hard part is in getting started. How can our single page application interact with our Grails 3 back end? Below are some basic examples for beginners. Here are some Grails 3 Vue.js Hello World Examples.

Groovy Switch Statement Examples

The Switch statement in Groovy is more powerful than in Java. There are things that are easy to do in Groovy switch statements that are not available in Java. It is also more concise and easier to read. Below are several examples on how to use Groovy switch statements.

Groovy List Tutorial And Examples

A list is a common data structure that is used to store a collection of data. This can be used to store varying amount of data where the number of items is only determined at run time. Or it can also be used to store large amount of data where having different variables for each is not practical. Below are examples on how to use and manipulate List in Groovy.

Groovy Substring Examples

Getting a substring from another String is one of the basic building blocks of String manipulation. Most programming languages supports it out of the box. In Groovy, there are some cool ways of how to perform this operation. Below are some examples on different ways of getting substrings in Groovy.

Groovy Array Length

Array manipulation is common in any programming language. Here is a sample code on how to get the the length of an array in Groovy.

Groovy Copy File Examples

When writing batch programs, it is common to write code to copy files from one directory to another. Here are examples on how to Copy Files in Groovy.

Groovy FindAll

Groovy is popular for writing short and concise codes. Programs that contains many lines of code using Java can be shortened in Groovy. This greatly helps in developer productivity. A feature that is commonly used in Groovy is in searching for items in a collection. The Groovy FindAll method searches for a subset of a collection that matches a given criteria. Here are some examples on how to use Groovy FindAll:

Groovy Find

Groovy is one of the coolest language available because it makes coding so much easier. Long Java codes can be written in Groovy in fewer lines that are much more readable. One of the most used feature in Groovy is in searching. The Groovy Find method can be used to search for a single object in a collection, given a condition on what needs to be searched for. Below are some examples on how to use Groovy Find for searching.

Groovy Def Declaration Examples

When we declare a variable or function in Groovy, we can use the def keyword to define the type. The Groovy Def can be used if we don't want to restrict the type of an object. Hence, we can change what can be assigned to a variable any time during runtime. When we use Groovy def to declare something, it is similar to declaring it as an Object class. Because the class Object is the root class of all classes, you can assign anything to a variable of type Object. Here are some examples on how to use def in Groovy.