You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by hussayn <hu...@saxess.com> on 2008/09/12 11:10:45 UTC

How can i activate XSP in cocoon-2.2 ?

Hi;

I am experimenting with cocoon-2.2 and this is what i want to do right now: 

I have a lot of backend-java code, which contains a whole lot of business
logic. 
I want to embed call to the java backend in my cocoon-generated pages.

Now i first thought, XSP is my choice, so i searched for this and found the
following tutorial:

    http://cocoon.apache.org/2.1/userdocs/xsp/logicsheet.html

But XSP won't work for me. I just get the content of my XML file, 
so apparently there is no XSP running for me. 
Well, sure, it is cocoon-2.2 and probably XSP has been factored out...
After some investigation i found this thread:

    http://www.nabble.com/cocoon-%2B-db4odjects.jar-to18689963.html

I don't understand the answer ;-(  Where will i place the mentioned
funtion() and how will i have
to setup my stuff? So i after further investigation i found this thread:

    http://cocoon.apache.org/2.2/blocks/flowscript/1.0/1241_1_1.html

Now i understand the previous mentioned thread to some extend. And i ask
myself: 
has XSP been fully replaced by "flow-script" in cocoon-2.2 ?
Further investigations seem necessary ... and i found this thread:

    http://markmail.org/message/q5rgdefktbqt4ypj

The author mentions "the xsp-block" . I could not find such a block in the
list of cocoon-2.2 blocks.
Is XSP after all a deprecated technology ? From the introduction chapter in
this thread:

    http://cocoon.apache.org/2.2/core-modules/core/2.2/1375_1_1.html

i get the feeling, XSP is evil and i should move to something else
(flow-script?)  

How shall i proceed ? I will try the flow-script way now, but i am
absolutely
unsure, it doesnt feel right ? Flowscript smells like client side, but i am
entirely
server side (well i thought i use dojo for interaction... hmm) 

I can't say, that cocoon-2.2 is an easy tool...

Thank you for any hint.
regards, hussayn

-- 
View this message in context: http://www.nabble.com/How-can-i-activate-XSP-in-cocoon-2.2---tp19452293p19452293.html
Sent from the Cocoon - Users mailing list archive at Nabble.com.


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


Re: How can i activate XSP in cocoon-2.2 ?

Posted by Mark Lundquist <ml...@wrinkledog.com>.
On Sep 13, 2008, at 1:35 AM, hussayn wrote:

> [examples snipped...] Is that more or less a correct description of  
> the nuts and bolts ?

Yes, exactly, you are totally getting it now! :-)

cheers,
—ml—


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


Re: How can i activate XSP in cocoon-2.2 ?

Posted by Mark Lundquist <ml...@wrinkledog.com>.
On Sep 13, 2008, at 1:35 AM, hussayn wrote:

> 1.) Create a flowScript (e.g. main.js).
> In that flowscript prepare all data by accessing the relevant beans,
> possibly trigger calculations by calling bean-methods,
> and fetching the relevant data by accessing the bean getters
                                                                
^^^^^^^^^^^^^^^^^^

also you should know that flowscript and JXTemplate both understand  
beanhood and support element notation for invoking get/set methods.   
So, e.g..

In Java:

	public String getFoo();
	public void setFoo (final String foo);

In flowscript:

	var foo = theThing.foo;			// is the same is theThing.getFoo();
	theThing.foo = bar;				// is the same as theThing.setFoo (bar);

In JXTemplate:

	${theThing.foo}					// is the same as ${theThing.getFoo()}


(You can of course call getters/setters directly too).

cheers,
—ml—



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


Re: How can i activate XSP in cocoon-2.2 ?

Posted by Mark Lundquist <ml...@wrinkledog.com>.
On Sep 13, 2008, at 1:35 AM, hussayn wrote:

> [...]
>  cocoon.sendPageAndWait("helloWorld.jx", { date: now } );
> [...]

BTW... make sure you understand the difference between  
sendPageAndWait() and sendPage().  It has to do with continuations,  
and I don't have time to explain it now but you will understand it if  
you study the documentation of the flow object model and CForms which  
will give you a fair idea of how continuations work.

cheers,
—ml—





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


Re: How can i activate XSP in cocoon-2.2 ?

Posted by hussayn <hu...@saxess.com>.

Mark Lundquist-2 wrote:
> 
>> Now i understood, that the flow-script is indeed  
>> javascript, but it only regulates the when which page will be called, 
>> yes server side, and  no, thats not where
>> the business logic is placed, that is in the jx-templates served by the
>> JXTemplateGenerator
> 
> Actually no.  Business logic doesn't belong anywhere near JXTemplates.
> 
> ...
> 
> Flowscript should be the bridge to your Java stuff (the business  
> logic).  You use flowscript to program the controller layer.
> 
>> So i expect now, that i can feed my java based backend into the
>> JXTemplateGenerator
> 
> No, not directly.  Flowscript calls your Java backend objects and  
> injects data from them into the presentation templates via calls to  
> cocoon.sendPage().  (The sendPage() is called on some resources that  
> maps to a pipeline that starts with JXTemplateGenerator).
> 
>> and that is almost where i want to get... The last bit i need is, how to  
>> introduce my own classes.
>>
>> I guess it is sufficient to pack them into a jar file and then  
>> simply adress
>> them out of the *.jx files ?
> 
> No, call them from flowscript.
> 
>> My classes already conform to beans, so they have getters and  
>> setters. is
>> that enough ?
> 
> I don't know, I guess it depends, see below.
> 
>> or do i have to register my classes as beans to spring ? well... i  
>> will see
>> ;-)
> 
> I like to use Spring to create a "services layer" object.  Spring  
> takes care of all the plumbing and initialization and finding things  
> or whatever has to happen to get that services layer fired up at  
> initialization time (e.g., the first time the flowscript is invoked).   
> Flowscript asks Spring for the services layer bean and then calls its  
> methods.
> 

ah... ok, so is the following picture correct ?

+++++++++++++++++++++++++++++++++++++
The preferred approach is as follows:

1.) Create a flowScript (e.g. main.js). 
In that flowscript prepare all data by accessing the relevant beans, 
possibly trigger calculations by calling bean-methods, 
and fetching the relevant data by accessing the bean getters.
Or simply instantiate java objects directly:

function myHelloFunction() 
{
   var now = java.util.Date();
   cocoon.sendPageAndWait("helloWorld.jx", { date: now } );
}

2.) and then in the jx-template page.jx: display what i get from flowscript:

<?xml version="1.0"?>
<html xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
  <head>
    <title>Hello flowscript</title>
  </head>
  <body>
    <h1>Hello world</h1>
    <h2>We are running at ${date} </h2>
    welcome to cocoon-flowscripts  
  </body>
</html>

========================

In principle i also could have written the flowscript:

function myHelloFunction() 
{
   cocoon.sendPageAndWait("helloWorld.jx");
}

and the jx-template:

<?xml version="1.0"?>
<html xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
  <head>
    <title>Hello flowscript</title>
  </head>
  <body>
    <h1>Hello world</h1>
    <h2>We are running at <jx:out value="${java.util.Date()}"/> </h2>
    welcome to cocoon-flowscripts  
  </body>
</html>

But this secnd (XSP-like) approach is evil, because:

i have to decide on the view layer, what data i want to display.
But the view layer shall never decide WHAT to display, 
but only HOW to display what has to be shown.
And that is why flowscripts have been invented...

So fetching the data from the flowscript is clearly preferred over fetching
the data from the jx-templates.
+++++++++++++++++++++++++++++++++++++++++++++++

Is that more or less a correct description of the nuts and bolts ?

regards, hussayn
-- 
View this message in context: http://www.nabble.com/How-can-i-activate-XSP-in-cocoon-2.2---tp19452293p19468587.html
Sent from the Cocoon - Users mailing list archive at Nabble.com.


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


Re: How can i activate XSP in cocoon-2.2 ?

Posted by hussayn <hu...@saxess.com>.
hi, Mark, DAVIGNON;

Thank you for all your valuable contribs. I already have incorporated most
of this
into a new upcoming video tutorial about flow script. I guess, you'd like
to get your name mentioned on the credit roll ? Would you like to review the
video
before  it is released ? (about end of september)

@DAVIGNON: Meanwhile i think, flowscript plus jx-templates are a good
alternative to XSP.
At least the whole freedom of XSP seems to be available, while the typically
complex 
page navigation issues adressed in XSP can cleanly be factored out to
flowscripts as far as 
i understand it. But to be sure, i'd like to ask, if there are any aspects
of XSP, which are 
NOT covered by flowscript/jx-templates ?

thanks again for your helpfull informations!
regards, 
hussayn
-- 
View this message in context: http://www.nabble.com/How-can-i-activate-XSP-in-cocoon-2.2---tp19452293p19491889.html
Sent from the Cocoon - Users mailing list archive at Nabble.com.


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


Re: How can i activate XSP in cocoon-2.2 ?

Posted by Mark Lundquist <ml...@wrinkledog.com>.
On Sep 12, 2008, at 8:53 AM, hussayn wrote:

> well, i am now quite a few steps further. Sometimes when you dig and  
> dig,
> you miss
> the obvious. Now i understood, that the flow-script is indeed  
> javascript,
> but it only
> regulates the when which page will be called, yes server side, and  
> no, thats
> not where
> the business logic is placed, tht is in the jx-templates served by the
> JXTemplateGenerator

Actually no.  Business logic doesn't belong anywhere near JXTemplates.

> (this is what you mean by "template block"? ).

yes

>  Well, it looks, like there
> finally i get the
> bridge to my java stuff...

Flowscript should be the bridge to your Java stuff (the business  
logic).  You use flowscript to program the controller layer.

> So i expect now, that i can feed my java based backend into the
> JXTemplateGenerator

No, not directly.  Flowscript calls your Java backend objects and  
injects data from them into the presentation templates via calls to  
cocoon.sendPage().  (The sendPage() is called on some resources that  
maps to a pipeline that starts with JXTemplateGenerator).

> and that is
> almost where i want to get... The last bit i need is, how to  
> introduce my
> own classes.
>
> I guess it is sufficient to pack them into a jar file and then  
> simply adress
> them out of the *.jx files ?

No, call them from flowscript.

> My classes already conform to beans, so they have getters and  
> setters. is
> that enough ?

I don't know, I guess it depends, see below.

> or do i have to register my classes as beans to spring ? well... i  
> will see
> ;-)

I like to use Spring to create a "services layer" object.  Spring  
takes care of all the plumbing and initialization and finding things  
or whatever has to happen to get that services layer fired up at  
initialization time (e.g., the first time the flowscript is invoked).   
Flowscript asks Spring for the services layer bean and then calls its  
methods.

HTH/cheers,

—ml—


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


Re: How can i activate XSP in cocoon-2.2 ?

Posted by hussayn <hu...@saxess.com>.
Hi, Mark;


Mark Lundquist-2 wrote:
> 
>> and i should move to something else
>> (flow-script?)
> 
> Yes, flowscript + template block
> 
>> How shall i proceed ? I will try the flow-script way now, but i am
>> absolutely
>> unsure, it doesnt feel right ? Flowscript smells like client side,  
>> but i am
>> entirely
>> server side (well i thought i use dojo for interaction... hmm)
> 
> No, flowscript is entirely a server-side technology.  I find it a very  
> pleasant way to program Cocoon applications.
> 

well, i am now quite a few steps further. Sometimes when you dig and dig,
you miss
the obvious. Now i understood, that the flow-script is indeed javascript,
but it only
regulates the when which page will be called, yes server side, and no, thats
not where
the business logic is placed, tht is in the jx-templates served by the
JXTemplateGenerator
(this is what you mean by "template block"? ).  Well, it looks, like there
finally i get the 
bridge to my java stuff...

So i expect now, that i can feed my java based backend into the
JXTemplateGenerator and that is
almost where i want to get... The last bit i need is, how to introduce my
own classes.

I guess it is sufficient to pack them into a jar file and then simply adress
them out of the *.jx files ?
My classes already conform to beans, so they have getters and setters. is
that enough ?
or do i have to register my classes as beans to spring ? well... i will see
;-)

Anyways, the stormy wheather clears up by now and it looks like i can get
further towards my 
goals quite fast now ;-) 

Thanks again for all input and clearification!

regards, hussayn
-- 
View this message in context: http://www.nabble.com/How-can-i-activate-XSP-in-cocoon-2.2---tp19452293p19458245.html
Sent from the Cocoon - Users mailing list archive at Nabble.com.


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


Re: How can i activate XSP in cocoon-2.2 ?

Posted by Mark Lundquist <ml...@wrinkledog.com>.
On Sep 12, 2008, at 2:10 AM, hussayn wrote:

> i get the feeling, XSP is evil

Yes... XSP is evil.

> and i should move to something else
> (flow-script?)

Yes, flowscript + template block

> How shall i proceed ? I will try the flow-script way now, but i am
> absolutely
> unsure, it doesnt feel right ? Flowscript smells like client side,  
> but i am
> entirely
> server side (well i thought i use dojo for interaction... hmm)

No, flowscript is entirely a server-side technology.  I find it a very  
pleasant way to program Cocoon applications.

cheers,
—ml—


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


Re: How can i activate XSP in cocoon-2.2 ?

Posted by hussayn <hu...@saxess.com>.
hi Andre,

thank you for your hints! this is interesting information. I did not find
any note about XSP been not supported by cocoon-2.2. From the documentation
i tend to understand, it is supported, but somehow "no any more state of the
art"...
But i could not find a single hint about how to activate it. Now as you say,
it is
not available (yet?), i understand, why i am struggling...


&quot;DAVIGNON Andre - CETE NP/DIODé/PANDOC&quot;-2 wrote:
> 
>> unsure, it doesnt feel right ? Flowscript smells like client side, but i
>> am
>> entirely
>> server side (well i thought i use dojo for interaction... hmm) 
> 
> Flowscript _is_ server side. I use flowscript for the CForms but i feel 
> more comfortable and confident with XSP for business logic.
> 
> I think i'm not the only person hoping for an XSP block in 2.2 one day...
> 

So flowscript uses javascript to operate on the server side ? oh...
erm... ok... yes, after a secnd look to what the function in the tutorial
does,
i realize, it is probably meant to run serverside...

So do i have to write my business logic in javascript ? Or can i feed in
java code as well somehow ?

As an alternative could i use
ServletService[Generator|Transformer|Serialiser] and implement
my business logic outside of cocoon using simple servlet technology, and let
these servlets be 
called from the cocoon-pipeline ? Probably not an optimal choice, but maybe
doable at least ?

Or would it make sense to simply implement my own
generator/transformer/serializer set that
helps me to integrate my business logic into cocoon ? That sounds like i
could get comfortable
with it... Or will i again bang my head against the next wall ;-) ... 

regards,
hussayn
-- 
View this message in context: http://www.nabble.com/How-can-i-activate-XSP-in-cocoon-2.2---tp19452293p19453550.html
Sent from the Cocoon - Users mailing list archive at Nabble.com.


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


Re: How can i activate XSP in cocoon-2.2 ?

Posted by DAVIGNON Andre - CETE NP/DIODé/PANDOC <An...@developpement-durable.gouv.fr>.
Hi Hussayn,

> Now i understand the previous mentioned thread to some extend. And i ask
> myself: 
> has XSP been fully replaced by "flow-script" in cocoon-2.2 ?
> Further investigations seem necessary ... and i found this thread:
> 
>     http://markmail.org/message/q5rgdefktbqt4ypj
> 
> The author mentions "the xsp-block" . I could not find such a block in the
> list of cocoon-2.2 blocks.

As far as i know there is no XSP block in 2.2.

> Is XSP after all a deprecated technology ? From the introduction chapter in
> this thread:
> 
>     http://cocoon.apache.org/2.2/core-modules/core/2.2/1375_1_1.html
> 
> i get the feeling, XSP is evil and i should move to something else
> (flow-script?)  


XSP are not always well considered, but there are hundreds of Cocoon 
apps with thousands lines of code in XSP.


> How shall i proceed ? I will try the flow-script way now, but i am
> absolutely
> unsure, it doesnt feel right ? Flowscript smells like client side, but i am
> entirely
> server side (well i thought i use dojo for interaction... hmm) 


Flowscript _is_ server side. I use flowscript for the CForms but i feel 
more comfortable and confident with XSP for business logic.


I think i'm not the only person hoping for an XSP block in 2.2 one day...

Cheers.

André


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