Return-Path: Delivered-To: apmail-cocoon-users-archive@www.apache.org Received: (qmail 88675 invoked from network); 17 Jan 2006 06:18:37 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 17 Jan 2006 06:18:37 -0000 Received: (qmail 23927 invoked by uid 500); 17 Jan 2006 06:18:32 -0000 Delivered-To: apmail-cocoon-users-archive@cocoon.apache.org Received: (qmail 23745 invoked by uid 500); 17 Jan 2006 06:18:31 -0000 Mailing-List: contact users-help@cocoon.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: users@cocoon.apache.org List-Id: Delivered-To: mailing list users@cocoon.apache.org Delivered-To: moderator for users@cocoon.apache.org Received: (qmail 2832 invoked by uid 99); 16 Jan 2006 23:32:59 -0000 X-ASF-Spam-Status: No, hits=0.3 required=10.0 tests=MAILTO_TO_SPAM_ADDR X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Message-ID: <43CC2CED.4070007@inf.tu-dresden.de> Date: Tue, 17 Jan 2006 00:31:57 +0100 From: Tino Breddin User-Agent: Thunderbird 1.5 (Macintosh/20051201) MIME-Version: 1.0 To: users@cocoon.apache.org Subject: Re: How to access the session context with flowscript? References: <00a301c61a9b$5d0109c0$a9a4269e@win.uninett.no> <43CBBC04.30802@inf.tu-dresden.de> <43CB71FF.6090306@gmail.com> In-Reply-To: <43CB71FF.6090306@gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: amavisd-new at inf.tu-dresden.de X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Hi, i am using the authentication framework ofrom cocoon with a custom Authenticator. The xml fragment .... is still put into the session, when a user logs in. Well, now i tried this one: function callTest() { importClass(org.apache.cocoon.components.CocoonComponentManager); importClass(org.apache.cocoon.webapps.session.SessionManager); var componentManager = CocoonComponentManager.getSitemapComponentManager(); var sessionManager = componentManager.lookup(SessionManager.ROLE); var user = sessionManager.getContextFragment( "authentication","/authentication/ID").getFirstChild().getNodeValue(); cocoon.sendPage("dynamictest",{"user":user}); <---- line 17 } The error: Description: org.apache.avalon.framework.CascadingRuntimeException: "file:/Users/Tino/Documents/workspace/Prototyp/protected/scripts/nav-access.js", line 17: uncaught JavaScript exception: at callTest (file:/Users/Tino/Documents/workspace/Prototyp/protected/scripts/nav-access.js, Line 17): java.lang.NullPointerException Thanks for your help, Tino philguillard schrieb: > Hi, > > It seems your cocoon.session.getAttribute("ID") returns null. Did you > set previously the ID in the session ? > Just in case (take it as suggestion) : > If you are working on auth-framework or portal (cause i see here the > "ID" term), all is put inside the session in XML format, then you > would need something like that to get it: > var user = sessionManager.getContextFragment( > "authentication","/authentication/ID").getFirstChild().getNodeValue(); > > Phil > > Tino Breddin wrote: > >> Hi, >> >> i tried a littlebit, but all i get is a "uncaught >> NullPointerException" error in line 14. My code is simple, i wanted >> to test, if the forwarding and getting the session information work, >> but they don't. Any help? >> >> Thanks, >> Tino >> >> My js code: >> >> function callTest() { >> var user = null; >> user = cocoon.session.getAttribute("ID"); >> cocoon.sendPage("dynamictest",{"user":user}); <--- line 14 >> } >> >> My sitemap code: >> >> >> >> >> >> >> >> >> >> >> >> >> My jx code: >> >> >> >> >> > href="screen.css" /> >> >> >>

The current user is ${user}

>> >> >>
>> Armaz Mellati schrieb: >> >>> Your idea is almost right as far as I can see. >>> >>> Just some small modifications needed. >>> >>> function callGetCode() { >>> var user = cocoon.session.getAttribute("ID"); >>> var csc = new CodeSnippetCreator(); >>> var code = csc.getCode(user); >>> >>> cocoon.sedPage("name-of-a-pileline-with-a-jx-template",{"code":code}); >>> } >>> All flow functions MUST return a response. They can't just returne a >>> code. >>> >>> >>> Regards, >>> Armaz >>> >>> >>> >>> >>>> -----Original Message----- >>>> From: Tino Breddin [mailto:s9600916@inf.tu-dresden.de] Sent: 16. >>>> januar 2006 10:20 >>>> To: users@cocoon.apache.org >>>> Subject: How to access the session context with flowscript? >>>> >>>> Hi, >>>> >>>> this is my first approach to flowscript, so i am confronted with 3 >>>> questions right now. >>>> I want to read the id of the current user from the session context, >>>> pass it to a java method and get the returned object and forward it >>>> to the pipeline. >>>> >>>> >>>> flowtest.js: >>>> >>>> importClass(my.package.CodeSnippetCreator); >>>> >>>> function callGetCode() { >>>> var user = cocoon.session.getAttribute("ID"); >>>> CodeSnippetCreator csc = new CodeSnippetCreator(); >>>> var code = csc.getCode(user); >>>> return code; >>>> } >>>> -------------------------- >>>> >>>> The requested code shall be xml, so that i can forward it to the >>>> pipeline, were the code will be aggregated with other parts. The >>>> java method getCode(String user) gets some information about the >>>> user and then creates a specific xml snippet. >>>> Is this way to access the session and call java right? Currently i >>>> can not test it, it is just a idea i had to write down :-) >>>> >>>> Thanks, >>>> Tino >>>> >>>> --------------------------------------------------------------------- >>>> 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 >>> >> >> >> >> --------------------------------------------------------------------- >> 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 --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org For additional commands, e-mail: users-help@cocoon.apache.org