grails webflow requested resource not available - grails

I'm using grails 2.4.2 and the webflow-plugin :webflow:2.1.0-SNAPSHOT (the stable one 2.0.8.1 throws compile errors on 2.4).
The applicatin start without errors, so I hope everything is fine...
And now I'm trying to define a webflow...
In my controller I have the following code:
def newPartnerFlow() {
createPartner {
on("addAdresse").to("finish")
on("cancel").to("finish")
on("save").to("finish")
}
finish {
redirect controller: "stGsPartner", action: "index"
}
}
and to start the flow from the PartnerIndex-view, I have the following code:
<g:link class="btn btn-default" action="newPartner">Create WEB-Flow</g:link>
if I click now on the button in the index-page, I get the following error from tomcat:
message /MyApp/stGsPartner/newPartner
description The requested resource is not available.
Do I miss something?
Thanks in advance.

At least in older versions of webflow that I have used, the flow definitions had to be defined as closure variables rather than methods.
def newPartnerFlow = {
}

Related

Grails action redirect call

I'm new to grails and would just like to learn one at a time.
How can I call an action from another action in the same controller:
class ListProjectsController {
def index () {
redriect(action: sampleMethod)
}
def sampleMethod () {
//some codes here
}
}
I tried redirect but this caused some error, help please?
here is a picture of the error message
http://i24.photobucket.com/albums/c22/Klifford_Kho/Capture_zps5j8nov9f.png
That's the old style from before Grails 2 when actions were closures. You could quote the name or refer to the closure directly by name. When using methods you can't refer to them as objects, so you just have to quote the name:
redirect(action: 'sampleMethod')
run grails clean command and update code to
redirect(action: 'sampleMethod')
You have misspelled the method name redirect as redriect.

New Grails controller doesn't seem to respond

Grails 2.3.6 here. I went into myapp/grails-app/controllers and manually added a new WidgetController.groovy class:
class WidgetController {
def fizz() {
redirect(url: "http://google.com")
}
}
Then I run my Grails app locally, and when I go to http://localhost:8080/myapp/widget/fizz I just get my custom "page does not exist" error page. No errors in the logs.
Note: I did not use the grails create-controller Widget command; I just added a new file manually. What is going on here and what can I do to fix it?
Try to add a blank fizz.gsp page to your view/widget and it will work.

Using Groovy Library in Grails and getting 'No suitable ClassLoader found for grab'

I'm playing around with Grails/Groovy and have some straight Groovy code working that utilizes groovy-wslite. That code starts as such
send-request.groovy
#Grab(group='com.github.groovy-wslite', module='groovy-wslite', version='1.1.0')
import wslite.soap.*
When I implement that into my Grails code and view the controller/action I get this
Error 500: Internal Server Error
URI: /FormProj/hello/trigger
Class: java.lang.RuntimeException
Message: No suitable ClassLoader found for grab
And here's the code in it's current state (I've tried a LOT of different things)
HelloController.groovy
package com.demo
import groovy.grape.Grape
class HelloController {
def index() { }
def sayHi() {
return [
greeting : "Hi there, ${ params.name }"
]
}
def trigger() {
Grape.grab(group:'com.github.groovy-wslite', module:'groovy-wslite', version:'1.1.0')
…
}
}
As I'm sure you notice I'm very green with Grails/Groovy and really all things Java. I do know there is a wslite plugin for Grails, but surely this can work too right?
Grails: 2.3.8
Groovy: 2.2.2
UPDATE
Based on Ian Robert's advice I have updated my BuildConfig file by adding this line to the dependencies block
compile 'com.github.groovy-wslite:groovy-wslite:1.1.0'
And updated my controller to look like this
HelloController.groovy
package ws.thejspot
import wslite.soap.*
class HelloController {
def index() { }
def sayHi() {
return [
greeting : "Hi there, ${ params.name }"
]
}
def trigger() {
def client = new SOAPClient('URL')
}
}
Unfortunately now the IDE, GGTS, shows an error in the controller 'unable to resolve class SOAPClient'
Rather than trying to download the dependencies with #Grab, you should use the standard Grails dependency mechanism - edit grails-app/conf/BuildConfig.groovy and look for the grails.project.dependency.resolution closure. Inside that, in the dependencies block you should add
compile 'com.github.groovy-wslite:groovy-wslite:1.1.0'
and remove anything Grape-related from the controller, leaving just the import wslite.soap.*
You will probably need to run
grails compile --refresh-dependencies
at least once to ensure that Grails picks up your change to BuildConfig - it deliberately doesn't do a full dependency resolve every time you compile, so as not to slow down the build too much, so you need to tell it to refresh when you know it needs to.

Async-feature in grails 2.0.0.M1

i am trying out the async-feature in grails. According to http://grails.org/doc/2.0.0.M1/guide/introduction.html#webFeatures it is now possible to use the servlet 3.0 async-feature in grails. So i tried the following code (copied from the doc):
def index() {
def ctx = startAsync()
ctx.start {
render "hello"
ctx.complete()
}
}
just to see if it works, sadly it does not work :/.
A groovy.lang.MissingMethodException is thrown. Message: No signature of method: grailsasync.ProductController.startAsync() is applicable for argument types: () values: []. While compiling i get no errors, only while executing.
So i ask myself what did i do wrong? Maybe someone has tried out the new Milestone of grails and can help me with that.
gz Aleks
Your code looks fine. Assuming you've already confirmed that you're running this on a container that supports v 3.0 of the Servlet specification, I'd create an issue about this in the Grails JIRA

Grails Blurb Plugin - Unable to resolve class Blurb

I'm working through the book Grails: A Quick-Start Guide and have come upon a problem. The book has me install the Blurb plugin, which seems to work, but states that we will be using it as if it were a domain class and using it a pre-existing controller. The code that I am to add to the controller looks like this
def blurb = Blurb.findByName("custom_${event.id}" )
if (!blurb){
blurb = new Blurb(name:"custom_${event.id}" , content:"" ).save()
}
When I do this I receive the same error in the IDE and the run output
'unable to resolve class Blurb' and I am directed specifically to this line blurb = new Blurb(name:"custom_${event.id}" , content:"" ).save()
Can anyone tell me what might be going wrong? I'm assuming the plugin is installed properly because if I try to access it's controller/action directly 'http://localhost:8080/TekDays/blurb/create' the plugin's provided view renders properly.
Thanks!
--
For reference I am using STS / Grails 1.3.7
Update 2011.05.12 7:45AM CST
I've attached a screenshot showing my project from the STS interface to show how my project is laid out in the event that it is package related as Burt indicated. The issue though is I'm not sure how do to the import statement so perhaps that screenshot will help.
Here is the current code in the Dashboard Controller.
package tekdays
class DashboardController {
...
}
I've tried adding the following lines per Burt's suggestion, but I obviously don't have it right
package tekdays
package my.package <--unexpected token: package
class DashboardController {
I tried changing out my with tekdays and default and both yield the same result.
Am I doing that wrong?
Thanks!
The Blurb class is in the default package, so if your controller is in a package you'll need to use a Groovy trick to access it:
package my.package
import Blurb as Blurb
class MyController {
def action = {
def blurb = Blurb.findByName("custom_${event.id}" )
if (!blurb) {
blurb = new Blurb(name:"custom_${event.id}" , content:"" ).save()
}
}
}

Resources