[groovy-user] Problem Accessing static protected fields with latest Groovy

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[groovy-user] Problem Accessing static protected fields with latest Groovy

graemer
Hi Guys,

I tried to upgrade to the latest Groovy embeddable jar for my work
stuff but it throws loads of compilation errors for references to
protected static variables.

Essentially, I am using Groovy to write WebWork actions which extend
my AbstractAction implemented that extends xworks ActionSupport (until
Grails is finished ;-). The ActionSupport class has protected fields
like SUCCESS, ERROR etc for the different response types. So for
example a simple action would look like:

class MyAction extends AbstractAction {
  public String executeAction() {
        return SUCCESS
  }
}

This unfortunately produces an error similar to:

the variable SUCCESS is undefined in the current scope
 @ line x, column x.

Is there something I need to do to get around this, have some rules
changed? Or is this a bug?

Cheers,

Graeme
Reply | Threaded
Open this post in threaded view
|

Re: [groovy-user] Problem Accessing static protected fields with latest Groovy

Jochen Theodorou
Graeme Rocher schrieb:

> Hi Guys,
>
> I tried to upgrade to the latest Groovy embeddable jar for my work
> stuff but it throws loads of compilation errors for references to
> protected static variables.
>
> Essentially, I am using Groovy to write WebWork actions which extend
> my AbstractAction implemented that extends xworks ActionSupport (until
> Grails is finished ;-). The ActionSupport class has protected fields
> like SUCCESS, ERROR etc for the different response types. So for
> example a simple action would look like:
>
> class MyAction extends AbstractAction {
>   public String executeAction() {
>         return SUCCESS
>   }
> }
>
> This unfortunately produces an error similar to:
>
> the variable SUCCESS is undefined in the current scope
>  @ line x, column x.
>
> Is there something I need to do to get around this, have some rules
> changed? Or is this a bug?

a compiletime error? oh...I have not added additional compile time
checks for variables... but you are talking about ActionSupport.SUCCESS,
where in your example is ActionSupport referenced? changing your code to

  class MyAction extends AbstractAction {
    public String executeAction() {
          return ActionSupport.SUCCESS
    }
  }

would surely solve the problem..

I am afraid this has to wait a few days

bye blackdrag
Reply | Threaded
Open this post in threaded view
|

Re: [groovy-user] Problem Accessing static protected fields with latest Groovy

graemer
On 23/11/05, Jochen Theodorou <[hidden email]> wrote:

> Graeme Rocher schrieb:
>
> > Hi Guys,
> >
> > I tried to upgrade to the latest Groovy embeddable jar for my work
> > stuff but it throws loads of compilation errors for references to
> > protected static variables.
> >
> > Essentially, I am using Groovy to write WebWork actions which extend
> > my AbstractAction implemented that extends xworks ActionSupport (until
> > Grails is finished ;-). The ActionSupport class has protected fields
> > like SUCCESS, ERROR etc for the different response types. So for
> > example a simple action would look like:
> >
> > class MyAction extends AbstractAction {
> >   public String executeAction() {
> >         return SUCCESS
> >   }
> > }
> >
> > This unfortunately produces an error similar to:
> >
> > the variable SUCCESS is undefined in the current scope
> >  @ line x, column x.
> >
> > Is there something I need to do to get around this, have some rules
> > changed? Or is this a bug?
>
> a compiletime error? oh...I have not added additional compile time
> checks for variables... but you are talking about ActionSupport.SUCCESS,
> where in your example is ActionSupport referenced? changing your code to
>
>   class MyAction extends AbstractAction {
>     public String executeAction() {
>           return ActionSupport.SUCCESS
>     }
>   }
>
> would surely solve the problem..

It would solve the problem, but makes little sense as AbstractAction
is a subclass of ActionSupport and therefore these protected statics
should be available to subclasses without the need to prefix them with
ActionSupport.

>
> I am afraid this has to wait a few days

Oke.
>
> bye blackdrag
>