On Mar 19, 2009, at 10:16 AM, Jan Cerny wrote:

> Hi,
> I'm trying to access session from a Groovy class, but I'm not  
> successful.
>
> When I have a simple script:
>
> <%
>  session = request.getSession(true);
>
>  counter = session.getValue("counter")
> %>
>
> - everything is OK.
>
> But when I have a class:
>
> class User {
>
> def counter = 0;
>
>  void setUser() {
>
>    session = request.getSession(true);
>    counter = session.getValue("counter")
>  }
>
>  String showCounter() {
>    return this.counter;
>  }
> }
>
> The Error message is No such property: request for class: User.
>
> So how should I access session from the class?

> You need to pass the request to your groovy class.
> See for example 
> http://platform.xwiki.org/xwiki/bin/view/DevGuide/GroovyClassHelloWorldTutorial

> Thanks
> -Vincent

Hi,
thanks for a quick response. Somehow I managed it. I thought I tried this way 
yesterday, but apparently I made a mistake somwhere.

Thanks,
Zik

_______________________________________________
users mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to