You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Tino Breddin <s9...@inf.tu-dresden.de> on 2006/01/16 10:19:48 UTC

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


Re: Error- Accessing widgets in flowscript

Posted by Pe...@gmx.net.
Ah, thanks :o)

-Pete 

> --- Ursprüngliche Nachricht ---
> Von: Bruno Dumon <br...@outerthought.org>
> An: users@cocoon.apache.org
> Betreff: Re: Error- Accessing widgets in flowscript
> Datum: Mon, 16 Jan 2006 17:05:37 +0100
> 
> On Mon, 2006-01-16 at 16:51 +0100, Peter.Neu@gmx.net wrote:
> > Hello,
> > 
> > I have some difficulties accessing the widget values in the flow script.
> > 
> > var form = new Form("registration_definition.xml");
> > var wid = form.getWidget();
> > wid.message.value = cocoon.parameters.defaultMessage;
> 
> You need to do:
> 
> wid.getChild("message").value = ...
> 
> > 
> > The last call throws this exception: 
> > org.mozilla.javascript.EcmaError: Cannot convert null to an object.
> > 
> > When I access the same widget in an jscript block in the form_definition
> > there is no problem. 
> > 
> >  <fd:javascript>
> >     var msg = this.lookupWidget("../message");
> >  msg.value = "Selecting." + + event.newValue ;
> > </fd:javascript>
> > 
> > What is the problem here? 
> > I use the sitemap form the simple form example of the user guide.
> > 
> > cheers,
> > 
> > Pete
> > 
> -- 
> Bruno Dumon                             http://outerthought.org/
> Outerthought - Open Source, Java & XML Competence Support Center
> bruno@outerthought.org                          bruno@apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 

-- 
Telefonieren Sie schon oder sparen Sie noch?
NEU: GMX Phone_Flat http://www.gmx.net/de/go/telefonie

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: Error- Accessing widgets in flowscript

Posted by Bruno Dumon <br...@outerthought.org>.
On Mon, 2006-01-16 at 16:51 +0100, Peter.Neu@gmx.net wrote:
> Hello,
> 
> I have some difficulties accessing the widget values in the flow script. 
> 
> var form = new Form("registration_definition.xml");
> var wid = form.getWidget();
> wid.message.value = cocoon.parameters.defaultMessage;

You need to do:

wid.getChild("message").value = ...

> 
> The last call throws this exception: 
> org.mozilla.javascript.EcmaError: Cannot convert null to an object.
> 
> When I access the same widget in an jscript block in the form_definition
> there is no problem. 
> 
>  <fd:javascript>
>     var msg = this.lookupWidget("../message");
>  msg.value = "Selecting." + + event.newValue ;
> </fd:javascript>
> 
> What is the problem here? 
> I use the sitemap form the simple form example of the user guide.
> 
> cheers,
> 
> Pete
> 
-- 
Bruno Dumon                             http://outerthought.org/
Outerthought - Open Source, Java & XML Competence Support Center
bruno@outerthought.org                          bruno@apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Error- Accessing widgets in flowscript

Posted by Pe...@gmx.net.
Hello,

I have some difficulties accessing the widget values in the flow script. 

var form = new Form("registration_definition.xml");
var wid = form.getWidget();
wid.message.value = cocoon.parameters.defaultMessage;

The last call throws this exception: 
org.mozilla.javascript.EcmaError: Cannot convert null to an object.

When I access the same widget in an jscript block in the form_definition
there is no problem. 

 <fd:javascript>
    var msg = this.lookupWidget("../message");
 msg.value = "Selecting." + + event.newValue ;
</fd:javascript>

What is the problem here? 
I use the sitemap form the simple form example of the user guide.

cheers,

Pete

-- 
Telefonieren Sie schon oder sparen Sie noch?
NEU: GMX Phone_Flat http://www.gmx.net/de/go/telefonie

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: How to access the session context with flowscript?

Posted by philguillard <ph...@gmail.com>.
Hum.. This is what i use to get session manager and context fragments in 
only 2 lines:

var sessionManager = 
cocoon.getComponent(Packages.org.apache.cocoon.webapps.session.SessionManager.ROLE);
var user= sessionManager.getContextFragment( 
"authentication","/authentication/ID").getFirstChild().getNodeValue();

Another hint, i think your pipeline should be inside the auth-protect 
action to access all that authentication context :
*    <map:match pattern="foo">
        <map:act type="auth-protect">
            <map:parameter name="handler" value="portal-handler"/>
            <map:parameter name="application" value="portal"/>
                    ...............
        </map:act> *
    </map:match> 

Hope it helps.

Phil

Tino Breddin wrote:

> Hi,
>
> i am using the authentication framework ofrom cocoon with a custom 
> Authenticator. The xml fragment <authentication><ID>.... 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:
>>>
>>>    <map:pipeline>
>>>            <map:match pattern="main">
>>>                 <map:call function="callTest">
>>>                 </map:call>
>>>             </map:match>
>>>             <map:match pattern="dynamictest">
>>>                 <map:generate type="jx" source="resources/test.jx"/>
>>>                 <map:serialize type="xhtml"/>
>>>             </map:match>
>>>        </map:pipeline>
>>>
>>> My jx code:
>>>
>>> <jx:template xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
>>>   <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
>>>            <head>
>>>                <link rel="stylesheet" media="screen" 
>>> href="screen.css" />
>>>            </head>
>>>            <body>
>>>                <p>The current user is ${user}</p>
>>>            </body>
>>>        </html>
>>> </jx:template>
>>> 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
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Re: How to access the session context with flowscript?

Posted by Tino Breddin <s9...@inf.tu-dresden.de>.
Hi,

i am using the authentication framework ofrom cocoon with a custom 
Authenticator. The xml fragment <authentication><ID>.... 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:
>>
>>    <map:pipeline>
>>            <map:match pattern="main">
>>                 <map:call function="callTest">
>>                 </map:call>
>>             </map:match>
>>             <map:match pattern="dynamictest">
>>                 <map:generate type="jx" source="resources/test.jx"/>
>>                 <map:serialize type="xhtml"/>
>>             </map:match>
>>        </map:pipeline>
>>
>> My jx code:
>>
>> <jx:template xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
>>   <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
>>            <head>
>>                <link rel="stylesheet" media="screen" 
>> href="screen.css" />
>>            </head>
>>            <body>
>>                <p>The current user is ${user}</p>
>>            </body>
>>        </html>
>> </jx:template>
>> 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


Re: How to access the session context with flowscript?

Posted by philguillard <ph...@gmail.com>.
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:
>
>    <map:pipeline>
>            <map:match pattern="main">
>                 <map:call function="callTest">
>                 </map:call>
>             </map:match>
>             <map:match pattern="dynamictest">
>                 <map:generate type="jx" source="resources/test.jx"/>
>                 <map:serialize type="xhtml"/>
>             </map:match>
>        </map:pipeline>
>
> My jx code:
>
> <jx:template xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
>   <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
>            <head>
>                <link rel="stylesheet" media="screen" href="screen.css" />
>            </head>
>            <body>
>                <p>The current user is ${user}</p>
>            </body>
>        </html>
> </jx:template>
> 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


Re: How to access the session context with flowscript?

Posted by Tino Breddin <s9...@inf.tu-dresden.de>.
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:

    <map:pipeline>
            <map:match pattern="main">
                 <map:call function="callTest">
                 </map:call>
             </map:match>
             <map:match pattern="dynamictest">
                 <map:generate type="jx" source="resources/test.jx"/>
                 <map:serialize type="xhtml"/>
             </map:match>
        </map:pipeline>

My jx code:

<jx:template xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
   <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
            <head>
                <link rel="stylesheet" media="screen" href="screen.css" />
            </head>
            <body>
                <p>The current user is ${user}</p>
            </body>
        </html>
</jx:template>
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


RE: How to access the session context with flowscript?

Posted by Armaz Mellati <ar...@uninett.no>.
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