You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Sebastien Arbogast <se...@gmail.com> on 2005/05/02 08:23:41 UTC
Re: Authentication alternatives
> If you want to use the session framework, it's much more complicated..
> Here's an example on two wrappper functions to get and set a string in
> a path inside the session framework. Pay attention on two things: a
> session can have many diferent contexts (for different kind of data,
> etc.), and to locate data, you use xpath. If a context is not defined
> and you try to access to it, it'll throw an exception, so be careful.
>
> function setData(path,value) {
> var contextManager=cocoon.getComponent(Packages.org.apache.cocoon.webapps.session.ContextManager.ROLE);
> var myContext;
> if (contextManager.existsContext(site))
> myContext=contextManager.getContext("mycontext");
> else myContext=contextManager.createContext("mycontext","","");
> myContext.setAttribute(path,value);
> cocoon.releaseComponent(contextManager);
> }
I'm trying to use Nacho's two wrapper functions but there is just one
thing I don't understand : what does the "site" parameter stand for in
call to contextManager.existsContext(site) ? Where does its value come
from ?
Thx in advance...
--
Sebastien ARBOGAST
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Authentication alternatives
Posted by Sebastien Arbogast <se...@gmail.com>.
Ok I've managed to setup my authentication mechanism with session
context thanks to you Nacho.
But I still have a little problem to get data from session context
using the session tranformer.
When my user is authenticated, I create a "schaman" session context
(the name of my application) and I set the "/user/name" attribute to
the name of the user and I display a home page with a welcome message
:
<content title="home" xmlns:i18n="http://apache.org/cocoon/i18n/2.1"
xmlns:jx="http://apache.org/cocoon/templates/jx/1.0"
xmlns:session="http://apache.org/cocoon/session/1.0">
<div>
<i18n:translate>
<i18n:text key="welcome_message"/>
<i18n:param><session:getxml context="schaman"
path="/user/name">test</session:getxml></i18n:param>
</i18n:translate>
</div>
</content>
And in the pipeline I call the session transformer of course but then
"test" is always displayed instead of the real user's name.
Do you have an idea ?
Thx in advance.
--
Sebastien ARBOGAST
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org
Re: Authentication alternatives
Posted by Nacho Jimenez <na...@gmail.com>.
Wooopsie!
Sorry, forget about "site", the correct line should say
if (contextManager.existsContext("mycontext"))
My cocoon aplication uses a kind of home-made virtual system and
handles serveral different websites, so I keep a different context for
each one of them. I cleaned the functions before sending them to you,
but I forgot to clean that line. :)
Sorry
2005/5/2, Sebastien Arbogast <se...@gmail.com>:
> > If you want to use the session framework, it's much more complicated..
> > Here's an example on two wrappper functions to get and set a string in
> > a path inside the session framework. Pay attention on two things: a
> > session can have many diferent contexts (for different kind of data,
> > etc.), and to locate data, you use xpath. If a context is not defined
> > and you try to access to it, it'll throw an exception, so be careful.
> >
> > function setData(path,value) {
> > var contextManager=cocoon.getComponent(Packages.org.apache.cocoon.webapps.session.ContextManager.ROLE);
> > var myContext;
> > if (contextManager.existsContext(site))
> > myContext=contextManager.getContext("mycontext");
> > else myContext=contextManager.createContext("mycontext","","");
> > myContext.setAttribute(path,value);
> > cocoon.releaseComponent(contextManager);
> > }
>
> I'm trying to use Nacho's two wrapper functions but there is just one
> thing I don't understand : what does the "site" parameter stand for in
> call to contextManager.existsContext(site) ? Where does its value come
> from ?
>
> Thx in advance...
>
> --
> Sebastien ARBOGAST
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org