cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tino Breddin <s9600...@inf.tu-dresden.de>
Subject Re: How to access the session context with flowscript?
Date Mon, 16 Jan 2006 15:30:12 GMT
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


Mime
View raw message