Broken Controller behaviour in 1.3.0.RC2?

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Broken Controller behaviour in 1.3.0.RC2?

mrt1nz
Hi guys,

in Grails 1.3.0.RC2 I found some strange behaviour with controllers that
I couldn't observe in 1.2.0. I added the following controller

class TempController {
     def xyz
     def handle = {
         render 'hello'
     }
}

to grails-app/controllers. After starting Grails and GETting
http://localhost:8080/example/temp I'm getting a 404 - resource not
found. However, when I comment out 'def xyz'

class TempController {
     //def xyz
     def handle = {
         render 'hello'
     }
}

everything works as expected i.e. 'hello' is written to the browser window.

Any ideas?

Thanks in advance for any help/feedback

Martin


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

RE: Broken Controller behaviour in 1.3.0.RC2?

Paulo Alexandre Freitas
Hi,

Maybe it's assuming the first declaration as the default action since you
are using /temp and not /temp/xyz ou /temp/handle.

If you comment "def xyz" it'll assume handle as the default action and
proper render "hello".

To avoid problems you should use:
def defaultAction = "handle"

http://www.grails.org/Controllers+-+Creating+Controllers+and+Actions

Just my opinion.

Regards,
KaLu10

-----Original Message-----
From: Martin Krasser [mailto:[hidden email]]
Sent: quinta-feira, 29 de Abril de 2010 18:59
To: [hidden email]
Subject: [grails-user] Broken Controller behaviour in 1.3.0.RC2?

Hi guys,

in Grails 1.3.0.RC2 I found some strange behaviour with controllers that
I couldn't observe in 1.2.0. I added the following controller

class TempController {
     def xyz
     def handle = {
         render 'hello'
     }
}

to grails-app/controllers. After starting Grails and GETting
http://localhost:8080/example/temp I'm getting a 404 - resource not
found. However, when I comment out 'def xyz'

class TempController {
     //def xyz
     def handle = {
         render 'hello'
     }
}

everything works as expected i.e. 'hello' is written to the browser window.

Any ideas?

Thanks in advance for any help/feedback

Martin


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email



---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Broken Controller behaviour in 1.3.0.RC2?

mrt1nz
Defining a default action doesn't help either. As a side note, I use
'def xyz' as instance variable that should be set by Grails' dependency
injection mechanism.

Oddly enough, if the controller is written like

class TempController {
     def defaultAction = "handle"
     def handle = {
         render 'hello'
     }
}

I'm getting a 404 too when visiting http://localhost:8080/example/temp 
(where 'example' is the application name)

This really looks like a bug. All these things worked properly in Grails
1.2.0 but are now broken in 1.3.0.RC2.

Thanks,
Martin

Am 30.04.2010 01:23, schrieb Paulo Alexandre Freitas:

> Hi,
>
> Maybe it's assuming the first declaration as the default action since you
> are using /temp and not /temp/xyz ou /temp/handle.
>
> If you comment "def xyz" it'll assume handle as the default action and
> proper render "hello".
>
> To avoid problems you should use:
> def defaultAction = "handle"
>
> http://www.grails.org/Controllers+-+Creating+Controllers+and+Actions
>
> Just my opinion.
>
> Regards,
> KaLu10
>
> -----Original Message-----
> From: Martin Krasser [mailto:[hidden email]]
> Sent: quinta-feira, 29 de Abril de 2010 18:59
> To: [hidden email]
> Subject: [grails-user] Broken Controller behaviour in 1.3.0.RC2?
>
> Hi guys,
>
> in Grails 1.3.0.RC2 I found some strange behaviour with controllers that
> I couldn't observe in 1.2.0. I added the following controller
>
> class TempController {
>       def xyz
>       def handle = {
>           render 'hello'
>       }
> }
>
> to grails-app/controllers. After starting Grails and GETting
> http://localhost:8080/example/temp I'm getting a 404 - resource not
> found. However, when I comment out 'def xyz'
>
> class TempController {
>       //def xyz
>       def handle = {
>           render 'hello'
>       }
> }
>
> everything works as expected i.e. 'hello' is written to the browser window.
>
> Any ideas?
>
> Thanks in advance for any help/feedback
>
> Martin
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>      http://xircles.codehaus.org/manage_email
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list, please visit:
>
>      http://xircles.codehaus.org/manage_email
>
>
>    


--
Martin Krasser

Blog: http://krasserm.blogspot.com
Twitter: http://twitter.com/mrt1nz


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Broken Controller behaviour in 1.3.0.RC2?

burtbeckwith
defaultAction has to be static.

If there's only one action in a controller it becomes the default action but if there's more than one then you need to specify it unless there's one called 'index'. It looks like using def for an instance variable is confusing this, but it's probably best to not rely on a single action becoming the default since you're likely to add more later.

Burt

>
> Defining a default action doesn't help either. As a side note, I use
> 'def xyz' as instance variable that should be set by Grails' dependency
> injection mechanism.
>
> Oddly enough, if the controller is written like
>
> class TempController {
>      def defaultAction = "handle"
>      def handle = {
>          render 'hello'
>      }
> }
>
> I'm getting a 404 too when visiting http://localhost:8080/example/temp 
> (where 'example' is the application name)
>
> This really looks like a bug. All these things worked properly in Grails
> 1.2.0 but are now broken in 1.3.0.RC2.
>
> Thanks,
> Martin
>
> Am 30.04.2010 01:23, schrieb Paulo Alexandre Freitas:
> > Hi,
> >
> > Maybe it's assuming the first declaration as the default action since you
> > are using /temp and not /temp/xyz ou /temp/handle.
> >
> > If you comment "def xyz" it'll assume handle as the default action and
> > proper render "hello".
> >
> > To avoid problems you should use:
> > def defaultAction = "handle"
> >
> > http://www.grails.org/Controllers+-+Creating+Controllers+and+Actions
> >
> > Just my opinion.
> >
> > Regards,
> > KaLu10
> >
> > -----Original Message-----
> > From: Martin Krasser [mailto:[hidden email]]
> > Sent: quinta-feira, 29 de Abril de 2010 18:59
> > To: [hidden email]
> > Subject: [grails-user] Broken Controller behaviour in 1.3.0.RC2?
> >
> > Hi guys,
> >
> > in Grails 1.3.0.RC2 I found some strange behaviour with controllers that
> > I couldn't observe in 1.2.0. I added the following controller
> >
> > class TempController {
> >       def xyz
> >       def handle = {
> >           render 'hello'
> >       }
> > }
> >
> > to grails-app/controllers. After starting Grails and GETting
> > http://localhost:8080/example/temp I'm getting a 404 - resource not
> > found. However, when I comment out 'def xyz'
> >
> > class TempController {
> >       //def xyz
> >       def handle = {
> >           render 'hello'
> >       }
> > }
> >
> > everything works as expected i.e. 'hello' is written to the browser window.
> >
> > Any ideas?
> >
> > Thanks in advance for any help/feedback
> >
> > Martin
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe from this list, please visit:
> >
> >      http://xircles.codehaus.org/manage_email
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe from this list, please visit:
> >
> >      http://xircles.codehaus.org/manage_email
> >
> >
> >    
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Broken Controller behaviour in 1.3.0.RC2?

mrt1nz
Am 30.04.2010 07:34, schrieb burtbeckwith:
defaultAction has to be static.

The Grails documentation is ambiguous here. Both static and non-static examples are given. However, my previous example works when using 'static def defaultAction = ...'.


If there's only one action in a controller it becomes the default action but if there's more than one then you need to specify it unless there's one called 'index'. It looks like using def for an instance variable is confusing this, but it's probably best to not rely on a single action becoming the default since you're likely to add more later.

Makes sense to me. Thanks!


Burt

>
> Defining a default action doesn't help either. As a side note, I use
> 'def xyz' as instance variable that should be set by Grails' dependency
> injection mechanism.
>
> Oddly enough, if the controller is written like
>
> class TempController {
>      def defaultAction = "handle"
>      def handle = {
>          render 'hello'
>      }
> }
>
> I'm getting a 404 too when visiting http://localhost:8080/example/temp 
> (where 'example' is the application name)
>
> This really looks like a bug. All these things worked properly in Grails
> 1.2.0 but are now broken in 1.3.0.RC2.
>
> Thanks,
> Martin
>
> Am 30.04.2010 01:23, schrieb Paulo Alexandre Freitas:
> > Hi,
> >
> > Maybe it's assuming the first declaration as the default action since you
> > are using /temp and not /temp/xyz ou /temp/handle.
> >
> > If you comment "def xyz" it'll assume handle as the default action and
> > proper render "hello".
> >
> > To avoid problems you should use:
> > def defaultAction = "handle"
> >
> > http://www.grails.org/Controllers+-+Creating+Controllers+and+Actions
> >
> > Just my opinion.
> >
> > Regards,
> > KaLu10
> >
> > -----Original Message-----
> > From: Martin Krasser [mailto:[hidden email]]
> > Sent: quinta-feira, 29 de Abril de 2010 18:59
> > To: [hidden email]
> > Subject: [grails-user] Broken Controller behaviour in 1.3.0.RC2?
> >
> > Hi guys,
> >
> > in Grails 1.3.0.RC2 I found some strange behaviour with controllers that
> > I couldn't observe in 1.2.0. I added the following controller
> >
> > class TempController {
> >       def xyz
> >       def handle = {
> >           render 'hello'
> >       }
> > }
> >
> > to grails-app/controllers. After starting Grails and GETting
> > http://localhost:8080/example/temp I'm getting a 404 - resource not
> > found. However, when I comment out 'def xyz'
> >
> > class TempController {
> >       //def xyz
> >       def handle = {
> >           render 'hello'
> >       }
> > }
> >
> > everything works as expected i.e. 'hello' is written to the browser window.
> >
> > Any ideas?
> >
> > Thanks in advance for any help/feedback
> >
> > Martin
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe from this list, please visit:
> >
> >      http://xircles.codehaus.org/manage_email
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe from this list, please visit:
> >
> >      http://xircles.codehaus.org/manage_email
> >
> >
> >    
>
>
>


View this message in context: Re: Broken Controller behaviour in 1.3.0.RC2?
Sent from the Grails - user mailing list archive at Nabble.com.


-- 
Martin Krasser

Blog: http://krasserm.blogspot.com
Twitter: http://twitter.com/mrt1nz
Reply | Threaded
Open this post in threaded view
|

Re: Broken Controller behaviour in 1.3.0.RC2?

burtbeckwith
The docs have been fixed for 1.3 final.

Burt

> Am 30.04.2010 07:34, schrieb burtbeckwith:
> > defaultAction has to be static.
>
> The Grails documentation is ambiguous here. Both static and non-static
> examples are given. However, my previous example works when using
> 'static def defaultAction = ...'.
>
> >
> > If there's only one action in a controller it becomes the default
> > action but if there's more than one then you need to specify it unless
> > there's one called 'index'. It looks like using def for an instance
> > variable is confusing this, but it's probably best to not rely on a
> > single action becoming the default since you're likely to add more later.
>
> Makes sense to me. Thanks!
>
> >
> > Burt
> >
> > >
> > > Defining a default action doesn't help either. As a side note, I use
> > > 'def xyz' as instance variable that should be set by Grails' dependency
> > > injection mechanism.
> > >
> > > Oddly enough, if the controller is written like
> > >
> > > class TempController {
> > >      def defaultAction = "handle"
> > >      def handle = {
> > >          render 'hello'
> > >      }
> > > }
> > >
> > > I'm getting a 404 too when visiting http://localhost:8080/example/temp
> > > (where 'example' is the application name)
> > >
> > > This really looks like a bug. All these things worked properly in
> > Grails
> > > 1.2.0 but are now broken in 1.3.0.RC2.
> > >
> > > Thanks,
> > > Martin
> > >
> > > Am 30.04.2010 01:23, schrieb Paulo Alexandre Freitas:
> > > > Hi,
> > > >
> > > > Maybe it's assuming the first declaration as the default action
> > since you
> > > > are using /temp and not /temp/xyz ou /temp/handle.
> > > >
> > > > If you comment "def xyz" it'll assume handle as the default action
> > and
> > > > proper render "hello".
> > > >
> > > > To avoid problems you should use:
> > > > def defaultAction = "handle"
> > > >
> > > > http://www.grails.org/Controllers+-+Creating+Controllers+and+Actions
> > > >
> > > > Just my opinion.
> > > >
> > > > Regards,
> > > > KaLu10
> > > >
> > > > -----Original Message-----
> > > > From: Martin Krasser [mailto:[hidden email]
> > </user/SendEmail.jtp?type=node&node=2076515&i=0>]
> > > > Sent: quinta-feira, 29 de Abril de 2010 18:59
> > > > To: [hidden email] </user/SendEmail.jtp?type=node&node=2076515&i=1>
> > > > Subject: [grails-user] Broken Controller behaviour in 1.3.0.RC2?
> > > >
> > > > Hi guys,
> > > >
> > > > in Grails 1.3.0.RC2 I found some strange behaviour with
> > controllers that
> > > > I couldn't observe in 1.2.0. I added the following controller
> > > >
> > > > class TempController {
> > > >       def xyz
> > > >       def handle = {
> > > >           render 'hello'
> > > >       }
> > > > }
> > > >
> > > > to grails-app/controllers. After starting Grails and GETting
> > > > http://localhost:8080/example/temp I'm getting a 404 - resource not
> > > > found. However, when I comment out 'def xyz'
> > > >
> > > > class TempController {
> > > >       //def xyz
> > > >       def handle = {
> > > >           render 'hello'
> > > >       }
> > > > }
> > > >
> > > > everything works as expected i.e. 'hello' is written to the
> > browser window.
> > > >
> > > > Any ideas?
> > > >
> > > > Thanks in advance for any help/feedback
> > > >
> > > > Martin
> > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe from this list, please visit:
> > > >
> > > > http://xircles.codehaus.org/manage_email
> > > >
> > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe from this list, please visit:
> > > >
> > > > http://xircles.codehaus.org/manage_email
> > > >
> > > >
> > > >
> > >
> > >
> > >
> >
> > ------------------------------------------------------------------------
> > View this message in context: Re: Broken Controller behaviour in
> > 1.3.0.RC2?
> > <http://grails.1312388.n4.nabble.com/Broken-Controller-behaviour-in-1-3-0-RC2-tp2075960p2076515.html>
> > Sent from the Grails - user mailing list archive
> > <http://grails.1312388.n4.nabble.com/Grails-user-f1312389.html> at
> > Nabble.com.
>
>
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email