You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Java Developer <de...@yahoo.com> on 2004/07/02 00:17:04 UTC

How to access Session/Request object inside Transformer class

Hi All, 

I am writing a webbapp which generates charts inside a dynamically
generated html page using cocoon and fins block. 

My problem is I m looking for a simpler way so that, in a pipeline, I
should be able to :

1. Generate the xml //Done ..not a problem
2. Transform into image stream // partially done...that is THE PROBLEM
3. Get the original xml back //Done..not a problem
4. Transform using xsl//Done..not a problem
5. Serialize into html //with image tag that points to step 2 generated
image. 

Currently I m saving the image generated in step 2 and html is reading
it..which includes an IO operation(which i obiviously want to avoid). 

Other way could be storing the image stream into session by modifying
step 2 transformer, later rendering the image using servlet or
jsp.(which is again a server call..but should be faster than IO, love
to know any better way of doing it)

My first question is how to access http request or session inside
cocoon transformer, and second is Am I trying to reinvent the wheel
again ? is anybody has a better way for displaying image in an html
page using cocoon in the current scenario ??

Thanks much for your help and suggestions. 

I apologize being so fussy sounding too demanding. 



=====
- Java Developer


		
__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail

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


Re: How to access Session/Request object inside Transformer class

Posted by Java Developer <de...@yahoo.com>.
Hey Jeorg, 

You are very correct, I have to use the same xml in generating the
image and rendering the page. I will trying using these transformer. 

Will get back to you soon.

-S

--- Joerg Heinicke <jo...@gmx.de> wrote:
> On 02.07.2004 08:28, Robin Wyles wrote:
> 
> > Hi,
> > 
> > I may be looking at this too simplistically, or missing part of
> your 
> > problem, but it appears to me that you are trying to achieve all
> this in 
> > one pipeline, when two would be easier.
> > 
> > 1st pipeline:
> > 1. Generate the xml
> > 2. Transform using xsl
> > 3. Serialize into html, with the src of your image tag pointing to
> 2nd 
> > matcher
> > 
> > 2nd pipeline:
> > 1. Generate xml
> > 2. Transform into image stream (I assume that you don't actually
> have to 
> > save it to disk)
> 
> And if I understand it correctly the XML of both pipelines (1.) is
> the 
> same, isn't it? That's were the FragmentExtractor comes into play:
> The 
> transformer matches on specific elements in the XML, extracts them, 
> replaces them with image elements and an href pointing to the XML 
> extract. The extract is stored temporarily. When the browser displays
> 
> the HTML from pipeline 1 it immediatly requests the images with their
> 
> hrefs. Now the generator comes into play: with the unique href
> pointing 
> to a specific xml extract the image can be generated.
> 
> The FragmentExtractor can be found in the batik block, so have you to
> 
> include this one. Unfortunately there is not much documentation
> available:
>
http://cocoon.apache.org/2.1/userdocs/transformers/extractor-transformer.html
>
http://cocoon.apache.org/2.1/userdocs/generators/extractor-generator.html
> But if my description above seems to match your requirements, I can
> help 
> you to get it running.
> 
> Joerg
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 


=====
- Java Developer


		
__________________________________
Do you Yahoo!?
Yahoo! Mail is new and improved - Check it out!
http://promotions.yahoo.com/new_mail

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


Re: How to access Session/Request object inside Transformer class

Posted by Joerg Heinicke <jo...@gmx.de>.
On 02.07.2004 08:28, Robin Wyles wrote:

> Hi,
> 
> I may be looking at this too simplistically, or missing part of your 
> problem, but it appears to me that you are trying to achieve all this in 
> one pipeline, when two would be easier.
> 
> 1st pipeline:
> 1. Generate the xml
> 2. Transform using xsl
> 3. Serialize into html, with the src of your image tag pointing to 2nd 
> matcher
> 
> 2nd pipeline:
> 1. Generate xml
> 2. Transform into image stream (I assume that you don't actually have to 
> save it to disk)

And if I understand it correctly the XML of both pipelines (1.) is the 
same, isn't it? That's were the FragmentExtractor comes into play: The 
transformer matches on specific elements in the XML, extracts them, 
replaces them with image elements and an href pointing to the XML 
extract. The extract is stored temporarily. When the browser displays 
the HTML from pipeline 1 it immediatly requests the images with their 
hrefs. Now the generator comes into play: with the unique href pointing 
to a specific xml extract the image can be generated.

The FragmentExtractor can be found in the batik block, so have you to 
include this one. Unfortunately there is not much documentation available:
http://cocoon.apache.org/2.1/userdocs/transformers/extractor-transformer.html
http://cocoon.apache.org/2.1/userdocs/generators/extractor-generator.html
But if my description above seems to match your requirements, I can help 
you to get it running.

Joerg

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


Re: How to access Session/Request object inside Transformer class

Posted by Java Developer <de...@yahoo.com>.
You are absolutely right Robin, it is really very simple when someone
is working only with Cocoon and Fins and the xml input data is not
coming from DB(which isn't the normal case). 
In my webapp scenario I have an existing webapp which is (as 90% of
webapps these days) based on Struts and charts is a very very tiny
part/enhancement of it. So i am using cocoon plugin to get it work with
struts. Now as you must have figured that part out we have only one
entry point to our webapp which is Struts servlet.

So considering your solution, which is very obvious and appropriate, my
dynamically generated html page will have a src with
"http://blah..getmeonlychart.do" ..and this makes it two calls to
server for one user request. 

I hope i explained it to you.

-S

--- Robin Wyles <ro...@robinwyles.com> wrote:
> Hi,
> 
> I may be looking at this too simplistically, or missing part of your 
> problem, but it appears to me that you are trying to achieve all this
> 
> in one pipeline, when two would be easier.
> 
> 1st pipeline:
> 1. Generate the xml
> 2. Transform using xsl
> 3. Serialize into html, with the src of your image tag pointing to
> 2nd 
> matcher
> 
> 2nd pipeline:
> 1. Generate xml
> 2. Transform into image stream (I assume that you don't actually have
> 
> to save it to disk)
> 
> I'm going to be using Fins in a project very soon, and I sort of 
> imagined that this was the way I would approach it for charts that
> are 
> truly dynamic, so any feedback would be appreciated...
> 
> Robin
> 
> 
> On 2 Jul 2004, at 00:17, Java Developer wrote:
> 
> > Hi All,
> >
> > I am writing a webbapp which generates charts inside a dynamically
> > generated html page using cocoon and fins block.
> >
> > My problem is I m looking for a simpler way so that, in a pipeline,
> I
> > should be able to :
> >
> > 1. Generate the xml //Done ..not a problem
> > 2. Transform into image stream // partially done...that is THE
> PROBLEM
> > 3. Get the original xml back //Done..not a problem
> > 4. Transform using xsl//Done..not a problem
> > 5. Serialize into html //with image tag that points to step 2
> generated
> > image.
> >
> > Currently I m saving the image generated in step 2 and html is
> reading
> > it..which includes an IO operation(which i obiviously want to
> avoid).
> >
> > Other way could be storing the image stream into session by
> modifying
> > step 2 transformer, later rendering the image using servlet or
> > jsp.(which is again a server call..but should be faster than IO,
> love
> > to know any better way of doing it)
> >
> > My first question is how to access http request or session inside
> > cocoon transformer, and second is Am I trying to reinvent the wheel
> > again ? is anybody has a better way for displaying image in an html
> > page using cocoon in the current scenario ??
> >
> > Thanks much for your help and suggestions.
> >
> > I apologize being so fussy sounding too demanding.
> >
> >
> >
> > =====
> > - Java Developer
> >
> >
> > 		
> > __________________________________
> > Do you Yahoo!?
> > Yahoo! Mail - 50x more storage than other providers!
> > http://promotions.yahoo.com/new_mail
> >
> >
> ---------------------------------------------------------------------
> > 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
> 
> 


=====
- Java Developer


		
__________________________________
Do you Yahoo!?
Yahoo! Mail Address AutoComplete - You start. We finish.
http://promotions.yahoo.com/new_mail 

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


Re: How to access Session/Request object inside Transformer class

Posted by Robin Wyles <ro...@robinwyles.com>.
Hi,

I may be looking at this too simplistically, or missing part of your 
problem, but it appears to me that you are trying to achieve all this 
in one pipeline, when two would be easier.

1st pipeline:
1. Generate the xml
2. Transform using xsl
3. Serialize into html, with the src of your image tag pointing to 2nd 
matcher

2nd pipeline:
1. Generate xml
2. Transform into image stream (I assume that you don't actually have 
to save it to disk)

I'm going to be using Fins in a project very soon, and I sort of 
imagined that this was the way I would approach it for charts that are 
truly dynamic, so any feedback would be appreciated...

Robin


On 2 Jul 2004, at 00:17, Java Developer wrote:

> Hi All,
>
> I am writing a webbapp which generates charts inside a dynamically
> generated html page using cocoon and fins block.
>
> My problem is I m looking for a simpler way so that, in a pipeline, I
> should be able to :
>
> 1. Generate the xml //Done ..not a problem
> 2. Transform into image stream // partially done...that is THE PROBLEM
> 3. Get the original xml back //Done..not a problem
> 4. Transform using xsl//Done..not a problem
> 5. Serialize into html //with image tag that points to step 2 generated
> image.
>
> Currently I m saving the image generated in step 2 and html is reading
> it..which includes an IO operation(which i obiviously want to avoid).
>
> Other way could be storing the image stream into session by modifying
> step 2 transformer, later rendering the image using servlet or
> jsp.(which is again a server call..but should be faster than IO, love
> to know any better way of doing it)
>
> My first question is how to access http request or session inside
> cocoon transformer, and second is Am I trying to reinvent the wheel
> again ? is anybody has a better way for displaying image in an html
> page using cocoon in the current scenario ??
>
> Thanks much for your help and suggestions.
>
> I apologize being so fussy sounding too demanding.
>
>
>
> =====
> - Java Developer
>
>
> 		
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - 50x more storage than other providers!
> http://promotions.yahoo.com/new_mail
>
> ---------------------------------------------------------------------
> 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 Session/Request object inside Transformer class

Posted by Java Developer <de...@yahoo.com>.
Thanks for your mail, but I really couldn't figure out how to use it. 

Just wanna rephrase my requirement : 
Out of two pipeline calls, from the main pipeline, first pipeline 
serializes into image-jpeg, and the other pipeline renders the html
page. Since I didn't and don't know how to take output from one
pipeline whose mime-type is image/jpeg, into the other pipeline and
append the img tag and display this image in the html output of the
other pipeline. 

FYI : I found out that inside setup mthd of Transformer I can get hold
of request and since session object..like 

        this.request = ObjectModelHelper.getRequest(objectModel);

But as i said I m not very comfortable with this solution and want to
know if there is any well or not very well known approach to it ?


Thanks much ...

-S

--- Joerg Heinicke <jo...@gmx.de> wrote:
> On 02.07.2004 00:17, Java Developer wrote:
> 
> > Hi All, 
> > 
> > I am writing a webbapp which generates charts inside a dynamically
> > generated html page using cocoon and fins block. 
> > 
> > My problem is I m looking for a simpler way so that, in a pipeline,
> I
> > should be able to :
> > 
> > 1. Generate the xml //Done ..not a problem
> > 2. Transform into image stream // partially done...that is THE
> PROBLEM
> > 3. Get the original xml back //Done..not a problem
> > 4. Transform using xsl//Done..not a problem
> > 5. Serialize into html //with image tag that points to step 2
> generated
> > image. 
> > 
> > Currently I m saving the image generated in step 2 and html is
> reading
> > it..which includes an IO operation(which i obiviously want to
> avoid). 
> > 
> > Other way could be storing the image stream into session by
> modifying
> > step 2 transformer, later rendering the image using servlet or
> > jsp.(which is again a server call..but should be faster than IO,
> love
> > to know any better way of doing it)
> > 
> > My first question is how to access http request or session inside
> > cocoon transformer, and second is Am I trying to reinvent the wheel
> > again ? is anybody has a better way for displaying image in an html
> > page using cocoon in the current scenario ??
> > 
> > Thanks much for your help and suggestions. 
> > 
> > I apologize being so fussy sounding too demanding. 
> 
> Have a look on the FragmentExtractorTransformer + Generator. From
> what I 
> understand it's exactly the thing you need.
> 
> Joerg
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 


=====
- Java Developer


		
__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail

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


Re: How to access Session/Request object inside Transformer class

Posted by Java Developer <de...@yahoo.com>.
Hey Jeorg, 

I apologize for my absentees, can you please suggest me some samples in
getting FragmentExtractorTransformer + generator working with my app. 

Thanks.
-S

--- Joerg Heinicke <jo...@gmx.de> wrote:
> On 02.07.2004 00:17, Java Developer wrote:
> 
> > Hi All, 
> > 
> > I am writing a webbapp which generates charts inside a dynamically
> > generated html page using cocoon and fins block. 
> > 
> > My problem is I m looking for a simpler way so that, in a pipeline,
> I
> > should be able to :
> > 
> > 1. Generate the xml //Done ..not a problem
> > 2. Transform into image stream // partially done...that is THE
> PROBLEM
> > 3. Get the original xml back //Done..not a problem
> > 4. Transform using xsl//Done..not a problem
> > 5. Serialize into html //with image tag that points to step 2
> generated
> > image. 
> > 
> > Currently I m saving the image generated in step 2 and html is
> reading
> > it..which includes an IO operation(which i obiviously want to
> avoid). 
> > 
> > Other way could be storing the image stream into session by
> modifying
> > step 2 transformer, later rendering the image using servlet or
> > jsp.(which is again a server call..but should be faster than IO,
> love
> > to know any better way of doing it)
> > 
> > My first question is how to access http request or session inside
> > cocoon transformer, and second is Am I trying to reinvent the wheel
> > again ? is anybody has a better way for displaying image in an html
> > page using cocoon in the current scenario ??
> > 
> > Thanks much for your help and suggestions. 
> > 
> > I apologize being so fussy sounding too demanding. 
> 
> Have a look on the FragmentExtractorTransformer + Generator. From
> what I 
> understand it's exactly the thing you need.
> 
> Joerg
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 


=====
- Java Developer


	
		
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail 

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


Re: How to access Session/Request object inside Transformer class

Posted by Java Developer <de...@yahoo.com>.
Hi Joerg, 

Thanks for the link, for the time being I have switched off the caching
for the generator. 

--- Joerg Heinicke <jo...@gmx.de> wrote:
> On 13.07.2004 23:58, Java Developer wrote:
> 
> > Hey Joerg, 
> > Thanks for your suggestion, I got rid of saving images for
> displaying
> > in my webapp. Got another problem with extractor..and after
> searching
> > in the mailing list i found this link 
> >
>
http://marc.theaimsgroup.com/?l=xml-cocoon-users&m=108193203317087&w=2
> 
> > 
> > I m also facing the same problem with getting fragment_id same for
> > different images, am using cocoon 2.1.4. 
> > 
> > Pls update if there is any patch available for the sae..or am I
> doing
> > anything wrong..
> 
> Sorry for my non-reacting, but I'm a bit short on time at the moment.
> 
> For the above mentioned problem there is a bug filed at 
> http://issues.apache.org/bugzilla/show_bug.cgi?id=28724. It contains
> the 
> reason for the behaviour, a general work around (don't use request 
> parameters for differences between fragments) and also Sarah's
> specific 
> work around to switch off caching.
> 
> Hope this helps for the moment,
> 
> Joerg
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 


=====
- Java Developer

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

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


Re: How to access Session/Request object inside Transformer class

Posted by Joerg Heinicke <jo...@gmx.de>.
On 13.07.2004 23:58, Java Developer wrote:

> Hey Joerg, 
> Thanks for your suggestion, I got rid of saving images for displaying
> in my webapp. Got another problem with extractor..and after searching
> in the mailing list i found this link 
> http://marc.theaimsgroup.com/?l=xml-cocoon-users&m=108193203317087&w=2 
> 
> I m also facing the same problem with getting fragment_id same for
> different images, am using cocoon 2.1.4. 
> 
> Pls update if there is any patch available for the sae..or am I doing
> anything wrong..

Sorry for my non-reacting, but I'm a bit short on time at the moment. 
For the above mentioned problem there is a bug filed at 
http://issues.apache.org/bugzilla/show_bug.cgi?id=28724. It contains the 
reason for the behaviour, a general work around (don't use request 
parameters for differences between fragments) and also Sarah's specific 
work around to switch off caching.

Hope this helps for the moment,

Joerg

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


Re: How to access Session/Request object inside Transformer class

Posted by Java Developer <de...@yahoo.com>.
Hey Joerg, 
Thanks for your suggestion, I got rid of saving images for displaying
in my webapp. Got another problem with extractor..and after searching
in the mailing list i found this link 
http://marc.theaimsgroup.com/?l=xml-cocoon-users&m=108193203317087&w=2 

I m also facing the same problem with getting fragment_id same for
different images, am using cocoon 2.1.4. 


Pls update if there is any patch available for the sae..or am I doing
anything wrong..


--- Joerg Heinicke <jo...@gmx.de> wrote:
> On 02.07.2004 00:17, Java Developer wrote:
> 
> > Hi All, 
> > 
> > I am writing a webbapp which generates charts inside a dynamically
> > generated html page using cocoon and fins block. 
> > 
> > My problem is I m looking for a simpler way so that, in a pipeline,
> I
> > should be able to :
> > 
> > 1. Generate the xml //Done ..not a problem
> > 2. Transform into image stream // partially done...that is THE
> PROBLEM
> > 3. Get the original xml back //Done..not a problem
> > 4. Transform using xsl//Done..not a problem
> > 5. Serialize into html //with image tag that points to step 2
> generated
> > image. 
> > 
> > Currently I m saving the image generated in step 2 and html is
> reading
> > it..which includes an IO operation(which i obiviously want to
> avoid). 
> > 
> > Other way could be storing the image stream into session by
> modifying
> > step 2 transformer, later rendering the image using servlet or
> > jsp.(which is again a server call..but should be faster than IO,
> love
> > to know any better way of doing it)
> > 
> > My first question is how to access http request or session inside
> > cocoon transformer, and second is Am I trying to reinvent the wheel
> > again ? is anybody has a better way for displaying image in an html
> > page using cocoon in the current scenario ??
> > 
> > Thanks much for your help and suggestions. 
> > 
> > I apologize being so fussy sounding too demanding. 
> 
> Have a look on the FragmentExtractorTransformer + Generator. From
> what I 
> understand it's exactly the thing you need.
> 
> Joerg
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
> For additional commands, e-mail: users-help@cocoon.apache.org
> 
> 


=====
- Java Developer


		
__________________________________
Do you Yahoo!?
Yahoo! Mail is new and improved - Check it out!
http://promotions.yahoo.com/new_mail

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


Re: How to access Session/Request object inside Transformer class

Posted by Joerg Heinicke <jo...@gmx.de>.
On 02.07.2004 00:17, Java Developer wrote:

> Hi All, 
> 
> I am writing a webbapp which generates charts inside a dynamically
> generated html page using cocoon and fins block. 
> 
> My problem is I m looking for a simpler way so that, in a pipeline, I
> should be able to :
> 
> 1. Generate the xml //Done ..not a problem
> 2. Transform into image stream // partially done...that is THE PROBLEM
> 3. Get the original xml back //Done..not a problem
> 4. Transform using xsl//Done..not a problem
> 5. Serialize into html //with image tag that points to step 2 generated
> image. 
> 
> Currently I m saving the image generated in step 2 and html is reading
> it..which includes an IO operation(which i obiviously want to avoid). 
> 
> Other way could be storing the image stream into session by modifying
> step 2 transformer, later rendering the image using servlet or
> jsp.(which is again a server call..but should be faster than IO, love
> to know any better way of doing it)
> 
> My first question is how to access http request or session inside
> cocoon transformer, and second is Am I trying to reinvent the wheel
> again ? is anybody has a better way for displaying image in an html
> page using cocoon in the current scenario ??
> 
> Thanks much for your help and suggestions. 
> 
> I apologize being so fussy sounding too demanding. 

Have a look on the FragmentExtractorTransformer + Generator. From what I 
understand it's exactly the thing you need.

Joerg

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