You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by JD...@genelogic.com on 2002/12/18 01:46:15 UTC

Session tool problems

I'm attempting to write a session tool to query the ACL when the user logs
in, cache the role data and assist in generating a menu for the user w/
role-based options. I was doing this previously making multiple calls to
data.getACL().hasRole("blah") but in this case every page generated 10+
queries looking for roles (are ACLs not cached after db-loading? why not? )
so I figured a session tool would be a good fit.

I have my tool declared as:

tool.session.mymenu=com.genelogic.projectname.tools.MenuTool

and the implementing class has a method called hasRole() that when first
run queries the logged-in user's ACL and caches the relevant role status.
The problem is that the tool doesn't ever seem to be in scope within a
document context (i.e. putting '$mymenu.hasRole("admin")' in a velocity
document prints '$mymenu.hasRole("admin")') but it DOES seem to be
instatiated over and over again with each user click as if it were a
request tool. I have a System.out debugging call in the constructor:

    /**
     * Constructor
     */
    public MenuTool() {
        System.out.println("\n\nINSTANTIATING TOOL!!\n\n");
    }

and with each click I get the printed text. Can anyone tell me what I'm
doing wrong in trying to create this session tool? The docs have examples
of global and request tools (and I'm using implementations of both
successfully) but session tools don't seem to be working well.

Thanks,
-j

-------------------------------------------------
James Diggans
Bioinformatics Programmer
Gene Logic, Inc.
Phone: 301.987.1756
FAX: 301.987.1701



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Session tool problems

Posted by "Henning P. Schmiedehausen" <hp...@intermeta.de>.
JDiggans@genelogic.com writes:

>instatiated over and over again with each user click as if it were a
>request tool. I have a System.out debugging call in the constructor:

>    /**
>     * Constructor
>     */
>    public MenuTool() {
>        System.out.println("\n\nINSTANTIATING TOOL!!\n\n");
>    }

>and with each click I get the printed text. Can anyone tell me what I'm
>doing wrong in trying to create this session tool? The docs have examples
>of global and request tools (and I'm using implementations of both
>successfully) but session tools don't seem to be working well.

You should use the init() method, not the C'tor.

	Regards
		Henning


-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen       -- Geschaeftsfuehrer
INTERMETA - Gesellschaft fuer Mehrwertdienste mbH     hps@intermeta.de

Am Schwabachgrund 22  Fon.: 09131 / 50654-0   info@intermeta.de
D-91054 Buckenhof     Fax.: 09131 / 50654-20   

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>