I've got a Grails controller which relies on the message taglib to resolve an i18n message:
class TokenController {
def passwordReset = {
def token = DatedToken.findById(params.id);
if (!isValidToken(token, params)) {
flash.message = message(code: "forgotPassword.reset.invalidToken")
redirect controller: 'forgotP...
Article {
String categoryName
static hasMany = [
tags: Tag
]
}
Tag {
String name
}
Now I want to find the list of all related articles. Related meaning, all articles that have the same category name as myArticle or any of the same tags as myArtcle.
With only matching categoryName, here is how I would get...
I think I'm missing a very obvious solution here, but I'll ask anyway. I've got a grails application that uses the Spring Security Plugin for my AAS. I want to start doing daily build and deploys of the application using Hudson onto a test server (running Apache2/Tomcat6) as the ROOT application. When the application goes live, anonym...
I need to be able to find all items in a table where the id of each item is not in a relational mapping table. In other words, I have one table where each row has an id. If that id is in a map table, it should not show up in my list.
I was thinking of querying my map table for all id's in it, then turning around and querying my main t...
I have 2 domain classes with a many-to-many relationship in grails: decks and cards.
The setup looks like this:
class Deck {
static hasMany = [cards: Card]
}
class Card {
static hasMany = [decks: Deck]
static belongsTo = Deck
}
After I delete a deck, I want to also delete all cards which no longer belong to a deck. The easiest way t...
I have a grails project and a jar file in the lib directory of the grails project. The problem is when i run the app I get class not found errors on classes within the jar file. Why can these not be seen by the grails app?
...
I'm looking for a method or current API that allows you to add on tokens to web app requests.
Maybe within the session but not persisted.
Or if you could help me by outlining an efficient method for doing this
E.g.
1. GET request => Servlet generates a token and prints it in the view
2. returns a view with a hidden token
<input typ...
In my rails app that I am porting to grails whenever an unexpected error occurs I intercept the error automatically and display a form to the user informing them that an error has occured and asking them for further information. Meanwhile, as the form is rendered I write the stack trace and other information about who was logged in to a...
Hi,
I'm having problems to get browser's back button work properly on web flow.
Version of grails is 1.1.2.
Imagine example code:
def someFlow = {
...
fillGroup {
on("addMember"){
...
}.to "fillMember"
}
fillMember {
on("addMember") {
...
}.to "fillMember"
on("goToCart").to "...
Hi
I have this code
def errorMap = validateParams(params)
if (errorMap) {
flash.errorMap = errorMap
return
}
My question is this: Can I combine the assignment in line #1 and evaluation of the condition in line#2 to make a one liner like the following:
if (flash.errorMap = validateParams(params)) {
return
}
Is it a bad pr...
I have a project using the Grails 1.1.1 application framework, and when I run grails test-app I am getting some odd results. I have a function that logs output at the INFO level, and another function using println. I have both a unit test and an integration test that access these two functions. When I look at the generated test report...
Hi
I have the following domain classes:
class User = {
String username
...
Company company
}
class Company {
String name
...
}
That is, there is a n:1 relationship between user and company.
These classes are so and I cannot change them.
At the show.gsp I want to have the details of the company togethe...
Hi,
I need to write Domain class constraint in Grails which says that one integer field must be greater or equal than the other.
When I write the code like this:
class MyDomain {
String title
int valueMin = 1
int valueMax = 1
static constraints = {
valueMin(min:1)
valueMax(min:valueMin)
}
}
I'm getting error:
Caused by: ...
I am banging my head up against the wall about what I think would be a very simple problem to resolve in Grails:
Say that I have shopping-cart-like model; so a class Cart that hasMany items, and each item belongsTo the cart. In general, I don't care about the order of the items in the cart - I don't care what order they're stored in, c...
I've written a plugin with a new artifact "Foo" that goes into the grails-app/foos/ directory. When I create a Foo then run the app, the Foo is picked up nicely ... when I 'touch grails-app/foos/MyFoo.groovy' the class reloads and onChange is called ... but, when I do 'create-foo MySecondFoo' I don't get an onChange call at all - I have ...
I have a gsp view, with an , and 2 input text.
I have a button to save and submit.
Now I would like to add another button with a new action, in my case a button to schedule save.
Note : in my controller I have define : def save (corresponding to button action save) and def schedule (corresponding to button action schedule).
What is th...
running with grails 1.1.1
package ssmithstone
class MyController {
def index = { }
def list = {
withFormat{
json{
render(contentType:"text/json"){
success(true)
}
}
}
}
def info = {
withFormat{
json{
render(contentType:"text/json"){
success(true)
...
I'm using Grails 1.2 and have the following many-to-many relationship setup:
class Employee {
static belongsTo = Store
static hasMany = [stores:Store]
}
class Store {
static hasMany = [employees:Employee]
}
I seed some data in Bootstrap.groovy:
store1.addToEmployees(employee1).save()
store1.addToEmployees(employee2).save...
I want to write a gsp file that takes a domain object and generates KML. I want to verify that specific elements are present depending on the domain object contents. How would I TDD this gsp file? I was thinking about writing a test that called the render method with a domain object but not sure how to call the render method from outs...
I had a grails 1.1 app working where keyword and description meta tags were dynamically generated. There was a change in how that works in 1.2, but I cannot found good documentation. I've tried numerous ways to make it work. No matter what I do the resultant html gets something like
<meta name="keywords"/>" />
instead of the actual...