I would stick to using the ContextManager interface rather than referencing the
implementation directly. That way you
code will continue to work even if the implementation or factory classes change.
For example, what would happen if the 'this.manager.lookup(ContextManager.ROLE)' call
passes back another
implementation of ContextManager? Your code will fall over. Mine won't.
You are ignoring one of the fundamental rules of OO. Do so at your own peril.
Paul.
--
Paul Bowler
Aventix Associates Ltd
---------- Original Message -----------
From: "iyy" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>, <[EMAIL PROTECTED]>
Sent: Wed, 22 Oct 2003 16:53:21 +0530
Subject: Re: Session.getAttribute problem: cocoon 2.1.3 dev
> Hi Mr. Bowler,
>
> Your code works brilliantly..
> Only correction I had to make was to use DefaultContextManager class instead
> of ContextManager.
> In the Cocoon 2.1.3 dev, ContextManager class in session jar is a
> interface.. implemented by DefaultContextManager.
>
> I am able to get session xml , and return a value to sitemap.
>
> Thank you very much,
>
> I have been working in Cocoon for more than an year now, and if you have any
> doubts about xsp,xml,xsl , pls
> feel free to write to me at : [EMAIL PROTECTED]
>
> From,
> iyyappan
>
> ----- Original Message -----
> From: "Paul Bowler" <[EMAIL PROTECTED]>
> To: "iyy" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> Sent: Wednesday, October 22, 2003 2:58 PM
> Subject: Re: Session.getAttribute problem: cocoon 2.1.3 dev
>
> > Actually, the code I gave was pulled directly out of one of my actions.
> >
> > Don't forget that to get the 'manager' object your component should
> implement composable (you should read up on the
> > Avalon framework if this is new to you).
> >
> > Here is some code for a dummy action that should get you started. No
> guarantees it is perfect though.
> >
> > public class DummyAction extends AbstractAction implements Composable {
> >
> > private ComponentManager manager;
> >
> > /**
> > * Composable
> > */
> > public void compose(ComponentManager manager) {
> > this.manager = manager;
> > }
> >
> > /**
> > *
> > */
> > public DummyAction() {
> > super();
> > }
> >
> > public Map act(Redirector redirector, SourceResolver resolver, Map
> objectModel, String source, Parameters
> > params) throws Exception {
> >
> > ContextManager cm = null;
> > cm = (ContextManager) this.manager.lookup(ContextManager.ROLE);
> > SessionContext context = cm.getContext("authentication");
> > // If no context then user has not logged on
> > if (context == null) {
> > return null;
> > }
> > DocumentFragment df = context.getXML("/authentication");
> > // User has logged on
> > NodeList nl = df.getChildNodes();
> > ... You code goes here
> > }
> > }
> >
> >
> > --
> > Paul Bowler
> > Aventix Associates Ltd
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >
------- End of Original Message -------
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]