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
_______________________________________________
users mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/users