--- Anna Afonchenko <[EMAIL PROTECTED]> wrote:
> Hi Geoff. Thanks for helping me.
> If you don't mind, I want to ask you some more
> questions, cause I still
> don't really understand what I have to do.
> 
> 1. I didin't find any example of xsp using Rhino.

You just need examples of java using rhino.  I was
recommending changing to regular java xsp.  You'll
need to use <xsp:structure> and <xsp:include> to make
sure the rhino classes you need are available in your
xsp and then later on in <xsp:logic> you can do
anything you would in a normal java class (because
when cocoon is done with your xsp file, it _will_ be a
normal java class.  If you haven't gone to look for
the .java source files that cocoon generates out of
your xsp (probably under tomcat's work/ directory) you
really should.  It would take some of the mystery out
of xsp.  Rhino is a javascript interpreter/engine
(whatever).  So within your xsp now written in java,
you'll retrieve your html page, pass on any regular
tags, and then pass the contents of the script tags to
the rhino instance.  To be very clear: I have no idea
if this is feasible and if you're not very comfortable
in java, the chances are slim you'll get this working
without more help than I or probably anyone else on
the list can provide.  I'm just suggesting an avenue
to try.

> Can you give me an
> example, or a URL to the page with example? I am
> sorry, but I tried hard to
> find examples, and I just didn't succeed.
 
I highly doubt that any examples exist of doing
exactly what you are trying.  

> In Cocoon
> documentation it is
> mentioned that Rhino can be used as an XSP scripting
> language, but they
> don't give any example.

They do - what they're talking about is xsp-js though.
 I'm suggesting you abandon xsp-js because of some of
the other things you need to do, and call the same
java-based javascript interpreter directly from your
java class (which xsp just helps you create.)  

> 2. Can I use JSGenerator instead of
> ServerPagesGenerator on the pipeline?

That's happening automatically when you declare that
your xsp's are written in javascript.  But you
probably don't want to do that anymore.  The only
reason you ever needed xsp-js was because it gave you
access to the Rhino javscript stuff behind the scenes.
 But it took away your ability to use the java stuff
you need.

> 
> All these things confuse me alot, and I'll be very
> happy if you gave me some
> more clues.
> Thank you very very much and sorry for attacking you
> with so many questions.
> 
> Anna

I can appreciate how confusing this must all seem to
someone new to cocoon, and even worse if you're new to
java - I'm sure all this just seems like absolute
voodoo.

Unfortunately, all I can give is clues because my own
time is limited and because you're trying something
fairly novel.

Best of luck,
Geoff

PS, it's a holiday later this week in the states, so I
may be off list for a while.

> 
> ----- Original Message -----
> From: "Geoff Howard" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, November 26, 2002 12:14 AM
> Subject: Re: JavaScript problems in XSP
> 
> 
> Ugh.  This may spell bad news: see inline comments.
> 
> If you are comfortable in java as well as javascript
> (at least reasonably so) you may want to look into
> using a java based javascript interpreter - looking
> into the cocoon javascript generator
>
(org.apache.cocoon.components.language.markup.xsp.JSGenerator)
> and other JS related sources around there in the
> source tree it looks like cocoon is using Rhino
> (http://www.mozilla.org/rhino/).  Then, you can
> write
> your xsp in java (which has far more features and
> users) but still execute arbitrary javascript code
> when you find it.  That said, I think you're on a
> potentially very confusing path because of all the
> places javascript can be in an html page, and all
> the
> DOM objects it's likely to reference.
> 
> Still, this may work and I'd be very interested to
> hear how it goes and help as I can - but I've never
> touched Rhino and can't right now.
> 
> Geoff (more comments below)
> 
> --- Anna Afonchenko <[EMAIL PROTECTED]> wrote:
> 
> > 1. First of all I tried to give the eval()
> function
> > some simple string that
> > I declared inside the <xsp:logic> tag: someStr =
> > "document.write('<center>Hello</center>')";
> > If I write this string inside the
> > <xsp:expr>document.text</xsp:expr>, the
> > output is:
> >
> > <?xml version="1.0" encoding="UTF-8" ?>
> > <page xmlns:xsp="http://apache.org/xsp";
> >
>
xmlns:xsp-request="http://apache.org/xsp/request/2.0";
> > xmlns:util="http://apache.org/xsp/util/2.0";>
> >   <p><center>Hello</center></p>
> >   </page>
> >
> > which is great, but when I looked in the source
> > code, I found out that  the
> > <center>Hello</center> string
> > is written using entities, e.g. it is not a
> node-set
> > of the output xml
> > document.
> 
> Right, sorry about that.  I had seen in another
> email
> that you were using <util:include-expr> so I left
> that
> part out for simplicity but forgot to comment as
> such.
> 
> >
> > Trying to enclose the <xsp:expr> tag inside the
> > <util:include-expr> tag:
> >
> >
>
<util:include-expr><util:expr><xsp:expr>document.text</xsp:expr></util:expr>
> > </util:include-expr>
> > the surprising output is:
> >
> >  <?xml version="1.0" encoding="UTF-8" ?>
> >  <page xmlns:xsp="http://apache.org/xsp";
> >
>
xmlns:xsp-request="http://apache.org/xsp/request/2.0";
> > xmlns:util="http://apache.org/xsp/util/2.0";>
> >  <p>
> >  <util:include-expr>
> >   <util:expr><center>Hello</center></util:expr>
> >   </util:include-expr>
> >   </p>
> >   </page>
> > This is strange. Do
> > you have any idea how
> > can I avoid outputting the result as a string
> (with
> > entities) rather that
> > outputting it as a node-set?
> 
> Not surprising - just checked and javascript xsp's
> have only request, response and session logicsheets.
> I don't know if it's possible to recreate the
> include
> expression functionality in javascript - you may
> want
> to send a very specific question on that to this
> list,
> making clear that you know it doesn't yet exist.
> 
> >
> >
> > 2. How can I retrieve the content of some html
> file
> > from xsp with
> > javascript?
> I don't know if you can - you can't from a browser,
> but that may be only because of the security
> limitations imposed.
> 
> > And parse it?
> See above.
> 
> > Is it possible that there are
> > problem using util
> > library from xsp with javascript?
> Right.  It doesn't exist in javascript.
> 
> Geoff
> 
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up
> now.
> http://mailplus.yahoo.com
> 
>
---------------------------------------------------------------------
> Please check that your question  has not already
> been answered in the
> FAQ before posting.    
> <http://xml.apache.org/cocoon/faq/index.html>
> 
> To unsubscribe, e-mail:    
> <[EMAIL PROTECTED]>
> For additional commands, e-mail:  
> <[EMAIL PROTECTED]>
> 
> 
>
---------------------------------------------------------------------
> Please check that your question  has not already
> been answered in the
> FAQ before posting.    
> <http://xml.apache.org/cocoon/faq/index.html>
> 
> To unsubscribe, e-mail:    
> <[EMAIL PROTECTED]>
> For additional commands, e-mail:  
> <[EMAIL PROTECTED]>
> 


__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

---------------------------------------------------------------------
Please check that your question  has not already been answered in the
FAQ before posting.     <http://xml.apache.org/cocoon/faq/index.html>

To unsubscribe, e-mail:     <[EMAIL PROTECTED]>
For additional commands, e-mail:   <[EMAIL PROTECTED]>

Reply via email to