More Enhancements to Grails:
Topics covered:
Grails Plugins
Resources
Restful API
Integration Tests
What’s new in grails 2.0
What’s new in grails 2.1
What’s new in grails 2.2
How to upgrade plugins
Implement react pagination with react hooks and react paginateKaty Slemon
ReactJS Pagination using React Hooks. Learn about how to implement pagination with React hooks and React paginate to manage and display the vast data conveniently.
Implement react pagination with react hooks and react paginateKaty Slemon
ReactJS Pagination using React Hooks. Learn about how to implement pagination with React hooks and React paginate to manage and display the vast data conveniently.
Veteran Ember NYCer Matthew Beale (@mixonic) will talk about the new APIs arriving soon in Ember. He'll cover how he and the rest of the team have implemented block params and bound attributes, and look at how top-level components, attrs, and opt-in two-way binding may look.
A full weekend of hands-on instruction from a senior software engineer. Over 6 past classes instructed!
AngularJS is a modern Javascript MVC application framework which provides features such as dependency injection, unit-testable components, templates, view routing, easy access to REST-based resources, and much more. This weekend workshop focuses on teaching you the fundamentals and the advanced application of AngularJS. All weekend you will dig into AngularJS hands-on and work through labs and exercises designed to give you a full understanding of AngularJS.
AtlasCamp 2015: Connect everywhere - Cloud and ServerAtlassian
Patrick Streule
You have an idea for an add-on? You want to tap into both the Atlassian Cloud and Server customer base without writing and maintaining it twice? Patrick illustrates some techniques you can use today to share most of your code between the Connect and the P2 add-on implementation.
AtlasCamp 2015: Using add-ons to build add-onsAtlassian
Daniel Wester, Wittified
Join Daniel Wester from Wittified as he shares his company secrets on tackling the everyday problems of add-on development and generating unique add-on ideas. Learn how you can apply his methods to your product development process and how you can make development easier with Web Fragment Finder.
AtlasCamp 2015: Web technologies you should be using nowAtlassian
Dallas Tester, Atlassian
Get a primer on the latest web technologies that you can leverage to build better applications. Topics covered include code re-use, loading JavaScript efficiently, and managing asynchronous operations using promises and Web workers.
In this presentation we explore the evolution of the Web frameworks and CSS from the dawn of the Web development to June 2015.
We describe React, as one of the modern ways to do Web development and we end up with Reactive programming and CSS modules as implemented in Webpack.
Veteran Ember NYCer Matthew Beale (@mixonic) will talk about the new APIs arriving soon in Ember. He'll cover how he and the rest of the team have implemented block params and bound attributes, and look at how top-level components, attrs, and opt-in two-way binding may look.
A full weekend of hands-on instruction from a senior software engineer. Over 6 past classes instructed!
AngularJS is a modern Javascript MVC application framework which provides features such as dependency injection, unit-testable components, templates, view routing, easy access to REST-based resources, and much more. This weekend workshop focuses on teaching you the fundamentals and the advanced application of AngularJS. All weekend you will dig into AngularJS hands-on and work through labs and exercises designed to give you a full understanding of AngularJS.
AtlasCamp 2015: Connect everywhere - Cloud and ServerAtlassian
Patrick Streule
You have an idea for an add-on? You want to tap into both the Atlassian Cloud and Server customer base without writing and maintaining it twice? Patrick illustrates some techniques you can use today to share most of your code between the Connect and the P2 add-on implementation.
AtlasCamp 2015: Using add-ons to build add-onsAtlassian
Daniel Wester, Wittified
Join Daniel Wester from Wittified as he shares his company secrets on tackling the everyday problems of add-on development and generating unique add-on ideas. Learn how you can apply his methods to your product development process and how you can make development easier with Web Fragment Finder.
AtlasCamp 2015: Web technologies you should be using nowAtlassian
Dallas Tester, Atlassian
Get a primer on the latest web technologies that you can leverage to build better applications. Topics covered include code re-use, loading JavaScript efficiently, and managing asynchronous operations using promises and Web workers.
In this presentation we explore the evolution of the Web frameworks and CSS from the dawn of the Web development to June 2015.
We describe React, as one of the modern ways to do Web development and we end up with Reactive programming and CSS modules as implemented in Webpack.
Slides from my talk on #ruby-mg meeting.
Intro about how we in catars.me are using postgREST to create fast and simple API that can be represented with various mithril.js components.
Information on an Appcelerator Alloy project demonstrating the use of a restApi sync adapter along with Model/Collection Databinding to a TableView
Complete Project here on Github: https://github.com/aaronksaunders/scs-backbonetest1
Talk given at JavaOne 2009 discussing how to build web applications using OSGi. The source for the demo found at http://github.com/mrdon/jforum-plugins/tree/master
Session Abstract: Enterprise Web applications tend to grow like weeds in monolithic complexity. OSGi, although more often associated with Java™ technology-based clients and application servers, can bring a new level of modularity, uptime, and stability that is needed with today's always-on hosted Web applications. OSGi gets really interesting when the pretty architecture diagrams meet the real world, because it consists of various deployment platforms, development environments, and application architectures. This presentation, for Java 2 Platform, Enterprise Edition (J2EE™ platform)-savvy architects and senior developers, provides a practical guide to the Web on OSGi, from integration approach to bundle development, to real-world code you can use today.
The session discusses
• What benefits OSGi brings to the J2EE platform
• Three integration strategies
• How to use Spring DM and Maven to ease development
• Lessons learned from Atlassian's recent OSGi deployment
• A production-ready example to use immediately
Modular Test-driven SPAs with Spring and AngularJSGunnar Hillert
Single-page Applications (SPA) are all the rage these days and with them there is an avalanche of new tools, libraries and frameworks we need to know. But what does this mean for us as Spring developers? In this session we will give you an overview of the current landscape and illustrate the choices the Spring XD team has made for its user interface. What do I use to write SPA applications? How do I integrate them into existing Spring-based backends? How do I build them? Can I integrate them into my existing Gradle or Maven build processes in order to achieve complete build automation? How do I integrate realtime messaging using Spring's SockJS/WebSocket support? In this talk we will answer these and many more questions. We will cover frameworks such as AngularJS, Bootstrap, RequireJS; tools like Bower, Grunt, Gulp; and also talk about testing using Karma and Protractor.
AngularJS training - Day 1 - Basics: Why, What and basic features of AngularJSmurtazahaveliwala
First part of AngularJS Training.
Covers details of AngularJs community and answers
- Why AngularJS ?
- What is AngularJS ?
- Getting started
- Basic Application layout and anatomies
- Data-binding, Existing Directives, Filters, Controllers
- Hosting on local (NodeJS) HTTPServer
Code samples available at
https://github.com/murtazahaveliwala/technext-angularjs-demo/tree/master/demos/static/angular-apps
This paper’s aim is to point out the RAD ( Rapid application development) elements present in the Microsoft’s MVC 3 and WCF 4.0 using Microsoft Visual Studio 2010. It will describe why creating a new web application using MVC 3 and WCF 4.0 is a easy and fast and also present simple ways to develop such applications.
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
Essentials of Automations: Optimizing FME Workflows with ParametersSafe Software
Are you looking to streamline your workflows and boost your projects’ efficiency? Do you find yourself searching for ways to add flexibility and control over your FME workflows? If so, you’re in the right place.
Join us for an insightful dive into the world of FME parameters, a critical element in optimizing workflow efficiency. This webinar marks the beginning of our three-part “Essentials of Automation” series. This first webinar is designed to equip you with the knowledge and skills to utilize parameters effectively: enhancing the flexibility, maintainability, and user control of your FME projects.
Here’s what you’ll gain:
- Essentials of FME Parameters: Understand the pivotal role of parameters, including Reader/Writer, Transformer, User, and FME Flow categories. Discover how they are the key to unlocking automation and optimization within your workflows.
- Practical Applications in FME Form: Delve into key user parameter types including choice, connections, and file URLs. Allow users to control how a workflow runs, making your workflows more reusable. Learn to import values and deliver the best user experience for your workflows while enhancing accuracy.
- Optimization Strategies in FME Flow: Explore the creation and strategic deployment of parameters in FME Flow, including the use of deployment and geometry parameters, to maximize workflow efficiency.
- Pro Tips for Success: Gain insights on parameterizing connections and leveraging new features like Conditional Visibility for clarity and simplicity.
We’ll wrap up with a glimpse into future webinars, followed by a Q&A session to address your specific questions surrounding this topic.
Don’t miss this opportunity to elevate your FME expertise and drive your projects to new heights of efficiency.
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Clients don’t know what they don’t know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clients’ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualityInflectra
In this insightful webinar, Inflectra explores how artificial intelligence (AI) is transforming software development and testing. Discover how AI-powered tools are revolutionizing every stage of the software development lifecycle (SDLC), from design and prototyping to testing, deployment, and monitoring.
Learn about:
• The Future of Testing: How AI is shifting testing towards verification, analysis, and higher-level skills, while reducing repetitive tasks.
• Test Automation: How AI-powered test case generation, optimization, and self-healing tests are making testing more efficient and effective.
• Visual Testing: Explore the emerging capabilities of AI in visual testing and how it's set to revolutionize UI verification.
• Inflectra's AI Solutions: See demonstrations of Inflectra's cutting-edge AI tools like the ChatGPT plugin and Azure Open AI platform, designed to streamline your testing process.
Whether you're a developer, tester, or QA professional, this webinar will give you valuable insights into how AI is shaping the future of software delivery.
JMeter webinar - integration with InfluxDB and GrafanaRTTS
Watch this recorded webinar about real-time monitoring of application performance. See how to integrate Apache JMeter, the open-source leader in performance testing, with InfluxDB, the open-source time-series database, and Grafana, the open-source analytics and visualization application.
In this webinar, we will review the benefits of leveraging InfluxDB and Grafana when executing load tests and demonstrate how these tools are used to visualize performance metrics.
Length: 30 minutes
Session Overview
-------------------------------------------
During this webinar, we will cover the following topics while demonstrating the integrations of JMeter, InfluxDB and Grafana:
- What out-of-the-box solutions are available for real-time monitoring JMeter tests?
- What are the benefits of integrating InfluxDB and Grafana into the load testing stack?
- Which features are provided by Grafana?
- Demonstration of InfluxDB and Grafana using a practice web application
To view the webinar recording, go to:
https://www.rttsweb.com/jmeter-integration-webinar
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
💥 Speed, accuracy, and scaling – discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Mining™:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing – with little to no training required
Get an exclusive demo of the new family of UiPath LLMs – GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
👨🏫 Andras Palfi, Senior Product Manager, UiPath
👩🏫 Lenka Dulovicova, Product Program Manager, UiPath
2. Grails Plugins
Resources
RestfulAPI
IntegrationTests
What’s new in grails 2.0
What’s new in grails 2.1
What’s new in grails 2.2
How to upgrade plugins
3. Grails Plugins:
InstallGrails plugins
Create a new plugin
Use custom plugin in multiple applications
6. Including resources - using tags:
Declaring modules:
You can declare resource modules in both
applications and plugins.There are a couple of ways
of doing this, but the most common approach is to
add one or more dedicated artifacts to the project.
For an application this might be grails-
app/conf/ApplicationResources.groovy.
8. "core", "utils" and "forms" are the names of our
application modules.
You can also see that the "utils" module depends on
"jquery“
If we look a bit deeper into the above module
definitions, we can see that individual resources are
declared within a module using "resource" plus a
URL.This URL is the location of the resource relative
to the web-app directory in your project. If you wish,
you can also add extra attributes for fine-grained
control of resources, in particular via the
"disposition" setting.
9. There are two standard dispositions: "head",
meaning that a resource goes inside the
<head> element, and "defer“.
By default,CSS files have a disposition of
"head" while Javascript files use "defer"
10. Including resources in a page
As you know, you previously had to declare
all your CSS and Javascript links explicitly in
your layouts and views.
So how does this change with the Resources
plugin? Instead of putting in links to
individual resources, you declare which
modules your page requires, which makes for
much conciser <head> blocks.
11. In addition, you specify where in the page the resource links
should go. Here's an example of a very simple layout using
Resources:
<html>
<head>
...
<r:require modules="common, jquery"/>
<r:layoutResources/>
</head>
<body>
...
<r:layoutResources/>
</body>
</html>
12. <r:require> tag tells Grails which static
resources to include in the page
<r:layoutResources> tags specify where the
links should go.
You should have two <r:layoutResources>
tags: one in <head> and the other in <body>.
Any resource with a disposition of "head" will
go where the first one is, while those with a
disposition of "defer" will be inserted at the
second's location.
13. Ad-hoc resources
The Resources plugin calls inline images and
scripts "ad-hoc resources".These typically
aren't declared in modules and are simply
processed as and when they are encountered
in the page.A standard inline image link looks
something like:
<img
src="${resource(dir:'images',file:'grails_logo.p
ng')}" ... />
15. Adding Layout file to view:
<g:applyLayout name="main" />
In this way you need not to include resources
on every view
16. Web services are all about providing a web API onto your
web application and are typically implemented in either
REST
or SOAP.
17. REST:
Using a RESTful solution
▪ The first step in creating an API for an application is
deciding what it should allow clients to do.
▪ After all, if a feature isn’t available in the API, a client
can’t use it.
▪ Working out what should go into the API isn’t always an
easy task, but during development you have scope to
experiment. Once the API is published, that’s it.You have
to avoid changes that will disrupt those software clients
that rely on it.
18. Adding elements to an API often causes fewer
problems than changing or removing existing
elements.
A good strategy is to start minimally and grow the
API as required.
REST is not really a technology in itself, but more an
architectural pattern.
19. REST is very simple and just involves using plain XML or
JSON as a communication medium, combined with URL
patterns that are "representational" of the underlying
system, and HTTP methods such as GET, PUT, POST
and DELETE.
Def handlePosts = {
if (request.method == "GET") {
...
}
else if (request.method == "POST") {
...
}
}
Each HTTP method maps to an action type.
For example GET for retrieving data, PUT for creating
data, POST for updating and so on. In this sense REST
fits quite well with CRUD.
20. URL patterns:
The first step to implementing REST with Grails is
to provide RESTful URL mappings:
static mappings = {
"/product/$id?"(resource:"product")
}
This maps the URI /product onto a
ProductController.
21. Each HTTP method such as GET, PUT, POST and
DELETE map to unique actions within the controller
as outlined by the table below:
Method Action
GET show
PUT update
POST save
DELETE delete
22. You can alter how HTTP methods are handled by
using URL Mappings to map to HTTP methods:
"/product/$id"(controller: "product") {
action = [GET: "show", PUT: "update", DELETE: "delete", POST: "save"]
}
However, unlike the resource argument used
previously, in this case Grails will not provide
automatic XML or JSON marshalling unless you
specify the parseRequest argument:
"/product/$id"(controller: "product", parseRequest: true) {
action = [GET: "show", PUT: "update", DELETE: "delete", POST: "save"]
}
23. Issuing a request with a method other than GET or
POST from a regular browser is not possible without
some help from Grails.
When defining a form you can specify an alternative
method such as DELETE:
<g:form controller="book" method="DELETE">
..
</g:form>
Grails will send a hidden parameter called _method,
which will be used as the request's HTTP method.
Another alternative for changing the method for non-
browser clients is to use the XHTTP-Method-Override to
specify the alternative method name.
24. XML Marshalling – Reading:
The controller can use Grails' XML marshalling support to
implement the GET method:
import grails.converters.XML
class ProductController {
def show() {
if (params.id && Product.exists(params.id)) {
def p = Product.findByName(params.id)
render p as XML
}
else {
def all = Product.list()
render all as XML
}
}
..
}
If there is an id we search for the Product by name and return it,
otherwise we return all Products.This way if we go to /products we
get all products, otherwise if we go to /product/MacBook we only
get a MacBook.
25. Using firefox Poster addon:
Install poster plugin on the firefox, and then
find it on the tools tab, and then you will be
able to send http requests to your application
and test your rest API requests and
responses.
27. UnitTesting:
Why are we starting with unit tests?
But as you’ll see later, you can also use Grails integration
tests for “unit testing” if you want.
There are two primary advantages of unit tests over
integration tests:
▪ They’re quicker to run.
▪ You can run them from within your IDE.
28. Useful assertions available to your test cases:
assertEquals(expected, actual) Compares two values or objects for equality using
the equals() method
assertTrue(value) Checks that the given value is true after being
coerced to a Boolean
assertFalse(value) Checks that the given value is false after being
coerced to a Boolean
assertNull(value) Checks that the given value is null
assertNotNull(value) Checks that the given value is not null
assertSame(expected, actual) Checks that two objects are the same instance
assertArrayEquals(expected,
actual)
Compares two arrays for equality, checking that
they have exactly the same elements
shouldFail(type, closure) Checks that the given closure throws an exception
of the given type, or any exception if type is omitted
29. Who are you mocking?
The process of mocking involves providing fake
versions of classes or methods that can be used in
place of the real implementations.
The cool thing is that you can control the behavior
of the mock object or method, so you can pass
known data to the object under test.
Mocking can be used at any level of testing, but
it’s most commonly associated with unit tests.
30. Many of the methods provided by
GrailsUnitTestCase are used to mock the dynamic
properties and methods that would normally be
injected into classes by Grails.
All of the mock*() methods provided by
GrailsUnitTestCase use metaclass programming to
add mock properties, methods, and objects.That
means you can add your own or override the
existing ones to fine-tune the behavior.
31. In addition, the mock validation performs real
Spring databinding, so the errors
property is a real instance of Spring’s Errors
interface.This allows you to check for
multiple constraint violations on a single
field.
32. IntegrationTesting:
Where unit tests are about testing individual,
atomic units of functionality (like classes and their
methods), integration tests are designed to test
larger parts of an application, such as a controller
and its dependencies together.
The main focus is on ensuring that the units work
together correctly—that they integrate properly.
33. In Grails, integration tests appear on the surface to be
unit tests. In fact, if you create a new integration test
with this command,
grails create-integration-test Book
The fundamental difference is that integration tests run
inside a full Grails environment, with a running database
and all those dynamic methods and properties that
you’re used to.
You don’t have to mock any of them. For all intents and
purposes, the tests run against a real instance of your
application.
34. The main thing missing is the servlet container, the
lack of which has certain repercussions.
Here is a summary of what works and what doesn’t:
All plugins that don’t exclude the test environment are loaded.
BootStrap is executed. Spring application context is fully populated.
Domain classes work against a live database (an in-memory HSQLDB,
by default).
All dynamic methods and properties are available.
Mock versions of the servlet request, response, and session are used.
NoGrails or servlet filters are executed.
URL mappings have no effect.
Views can’t be tested.
35. Under the hood:
Each integration test is run inside a transaction
that’s rolled back at the end of the test.This
means that no changes are committed to the
database. Also, the default Grails environment for
tests is “test”.
class MyController {
def myService
def show = {
def items = myService.fetchItemsFor(params.userId)
[ itemNames: items.collect { it.name } ]
}
}
36. what if the service method returns null instead?
There’s no reason it can’t do so, but now you can see
that the controller will throw a NullPointerException
because of the code items.collect {...}.
class MyControllerTests extends GroovyTestCase{
def myService
void testShowNoItems() {
def myController = new MyController()
myController.myService = myService
myController.params.userId = "glen"
def model = myController.show()
assertEquals 0, model["itemNames"].size()
}
}
37. approach for integration tests is different:
tests are run against a live database, so you create
data via the domain classes
as you do in the live application. But because you
are working against a database, there are no
guarantees that data will be returned in the order
you expect
38. When only an integration test will do:
Grails’ unit test support will get you a long way in
your testing endeavors, but there are gaps in its
coverage you need to be aware of.
In particular, it doesn’t give you any help with
either criteria or Hibernate Query Language (HQL)
queries, nor does it have any support for testing
URL mappings.
39. Testing URL mappings is a simple matter of
leveraging the GrailsUrlMappings-TestCase support
class:
Let’s say, for the sake of argument, that we have these
mappings:
class UrlMappings {
static mappings = {
"/basket/$username"(controller: "basket", action: "show")
"/$controller/$action?/$id?"()
"500"(view: "error")
}
}
41. loads all the application’s URL mappings and does all the
necessary preparation in setUp().themselves.
The foot soldier of URL mapping tests is the
assertUrlMapping() method B, which accepts a URL as the
first argument, and a controller and action as named ones.
In the first test, we make sure that the URL "/item/edit/123"
maps to the item controller and edit action, with the value
123 mapped to the id parameter.This method also checks
that the reverse
mapping works.
There is also a corresponding assertReverseUrlMapping()
method that accepts the same arguments as the other
assertion methods.
42. Reloading Agent
Grails 2.0 reloading mechanism no longer uses
class loaders, but instead uses a JVM agent to
reload changes to class files.This results in
greatly improved reliability when reloading
changes and also ensures that the class files
stored in disk remain consistent with the class
files loaded in memory.
which reduces the need to run the clean
command.
43. Clean Command
Purpose:
The clean command deletes all compiled
resources from the application. Since Groovy is a
compiled language, as with Java, this is
sometimes useful to clear old instances of
classes and ensure correct compilation. It's also a
good idea to run this script before running tests
or creating aWAR file to ensure a full
compilation occurs.
44. Enhanced Error Reporting and Diagnosis
Error reporting and problem diagnosis has
been greatly improved with a new errors view
that analyses stack traces and recursively
displays problem areas in your code:
45. Grails 2.0 now uses the H2 database instead
of HSQLDB, and enables the H2 database
console in development mode (at the URI
/dbconsole) to check the database
47. Binary Plugins
Grails plugins can now be packaged as JAR
files and published to standard maven
repositories.This even works for GSP and
static resources (with resources plugin 1.0.1).
48. Controller Actions as Methods
It is now possible to define controller actions as
methods instead of using closures as in previous
versions of Grails. In fact this is now the
preferred way of expressing an action. For
example:
// action as a method
def index() {
}
// action as a closure
def index = {
}
49. Binding Primitive Method Action Arguments
It is now possible to bind form parameters to action arguments
where the name of the form element matches the argument
name. For example given the following form:
<g:form name="myForm" action="save">
<input name="name" />
<input name="age" />
</g:form>
You can define an action that declares arguments for each input
and automatically converts the
parameters to the appropriate type:
def save(String name, int age) {
// remaining
}
50. Servlet 3.0 Async Features
Grails now supports Servlet 3.0 including the
Asynchronous programming model defined by the
specification:
def index() {
def ctx = startAsync()
ctx.start {
new Book(title:"The Stand").save()
render template:"books", model:[books:Book.list()]
ctx.complete()
}
}
51. Link Generation API
A general purpose LinkGenerator class is now
available.
that is usable anywhere within a Grails application
and not just within the context of a controller. For
example if you need to generate links in a service or
an asynchronous background job outside the scope of
a request:
LinkGenerator grailsLinkGenerator
def generateLink() {
grailsLinkGenerator.link(controller:"book",
action:"list")
}
52. Page RenderingAPI:
Like the LinkGenerator the new PageRenderer can be used to render
GSP pages outside the scope of a web request, such as in a scheduled job
or web service.The PageRenderer class features a very similarAPI to the
render method found within controllers:
grails.gsp.PageRenderer groovyPageRenderer
void welcomeUser(User user) {
def contents =
groovyPageRenderer.render(view:"/emails/welcomeLetter",
model:[user: user])
sendEmail {
to user.email
body contents
}
}
53. The PageRenderer service also allows you to
pre-process GSPs into HTML templates:
new
File("/path/to/welcome.html").withWriter { w
->
groovyPageRenderer.renderTo(view:"/page/c
ontent", w)
}
54. Filter Exclusions
Filters may now express controller, action and uri exclusions to offer more
options for expressing to which requests a particular filter should be applied.
filter1(actionExclude: 'log*') {
before = {
// …
}
}
filter2(controllerExclude: 'auth') {
before = {
// …
}
}
filter3(uriExclude: '/secure*') {
before = {
// …
}
}
56. Customizable URL Formats
The default URL Mapping mechanism supports camel case names
in the URLs.The default URL for accessing an action named
addNumbers in a controller named MathHelperController would
be something like /mathHelper/addNumbers. Grails allows for
the customization of this pattern and provides an implementation
which replaces the camel case convention with a hyphenated
convention that would support URLs like /math-helper/add-
numbers.To
enable hyphenated URLs assign a value of "hyphenated" to the
grails.web.url.converter
property in grails-app/conf/Config.groovy.
// grails-app/conf/Config.groovy
grails.web.url.converter = 'hyphenated'
57. Detached Criteria and Where Queries
Grails 2.0 features support for
DetachedCriteria which are criteria queries
that are not associated with any session or
connection and thus can be more easily
reused and composed.
58. New findOrCreate and findOrSave Methods
Domain classes have support for the findOrCreateWhere,
findOrSaveWhere, findOrCreateBy and findOrSaveBy query methods
which behave just like findWhere and findBy methods except that they
should never return null.
If a matching instance cannot be found in the database then a new
instance is created, populated with values represented in the query
parameters and returned. In the case of findOrSaveWhere and
findOrSaveBy, the instance is saved before being returned.
def book = Book.findOrCreateWhere(author: 'Douglas Adams', title:
"TheHitchiker's GuideToThe Galaxy")
def book = Book.findOrSaveWhere(author: 'Daniel Suarez', title:
'Daemon')
def book = Book.findOrCreateByAuthorAndTitle('Daniel Suarez',
'Daemon')
def book = Book.findOrSaveByAuthorAndTitle('Daniel Suarez',
'Daemon')
59. Multiple Data Sources Support
It is now possible to define multiple datasources
in DataSource.groovy and declare one or
more datasources a particular domain uses by
default:
class ZipCode {
String code
static mapping = {
datasource 'ZIP_CODES'
}
}
61. Database Reverse Engineering
A new database reverse engineering plugin
has been designed and built for Grails 2.0 that
allows you to generate a domain model from
an existing database schema.
63. Grails Command Aliases
The alias command may be used to define
aliases for grails commands.
The following command creates an alias
named rit (short for "run integration tests"):
grails alias rit test-app integration:
64. Cache Plugin
Grails 2.1 installs the cache plugin by default.
This plugin provides powerful and easy to use
cache functionality to applications and
plugins.
65. New GORM Methods
In Grails 2.1.1 domain classes now have static
methods named first and last to retrieve the
first and last instances from the datastore.
See the first and last documentation for
details.
66. Namespace Support for plugins:
Domain classes provided by a plugin will have
their default database table name prefixed
with the plugin name if the
grails.gorm.table.prefix.enabled config
property is set to true.
67. For example, if the PublishingUtilities plugin
provides a domain class named Book, the
default table name for that domain class will
be PUBLISHING_UTILITIES_BOOK if the
grails.gorm.table.prefix.enabled config
property is set to true.
68. URL Mappings may now include a plugin attribute to indicate that the
controller referenced in the mapping is provided by a particular
plugin.
static mappings = {
// requests to /bookAuthors will be handled by the
// AuthorController provided by the BookUtilities plugin
"/bookAuthors" {
controller = 'author'
plugin = 'bookUtilities'
}
// requests to /publishingAuthors will be handled by the
// AuthorController provided by the Publishing plugin
"/publishingAuthors" {
controller = 'author'
plugin = 'publishing'
}
}
69. Controller methods and GSPTags which
accept a controller name as a paramater now
support an optional parameter indicating that
the controller is provided by a specific plugin.
<g:link controller="user"
plugin="springSecurity">Manage
Users</g:link>
71. ForkedTomcat Execution
Grails 2.2 supports forked JVM execution of the
Tomcat container in development mode.This
has several benefits including:
• Reduced memory consumption, since the
Grails build system can exit
• Isolation of the build classpath from the
runtime classpath
•The ability to deploy other Grails/Spring
applications in parallel without conflicting
dependencies
72. SQL Projections In Criteria Queries
Grails 2.2 adds new functionality to criteria
queries to provide access to Hibernate's SQL
projection
73. following scripts to see what plugins needed updating
grails list-plugin-updates
To update a plugin you just run install-plugin again
and it'll detect that the plugin's already installed and
will remove the old one and install the new one. For a
small version delta this should be fine, but I'd do them
one at a time and test in-between (but do the 2
JQuery plugins together).
If you're lucky the plugin either has no compatibility
issues, or they're documented in the plugin docs, so
be sure to check there before upgrading.
74. From Grails 2.2 on, you should change the
plugins section of BuildConfig.groovy. After
that you can run grails list-plugin-updates
again and it will ask to update your
dependencies.