Mailing List Archive

Newbie with some javascript questions
I was looking at the FAQ on adding my own javascripts so I can use them
on my forrest page

I am new at using forrest mainly only have done simple pages in the past
using html and javascripts and some CSS.

but the FAQ lacks on a good description or example on what to edit and
where for adding my own js files for use.

I am writing a some javascripts to validate my a form prior to
submitting it to a php script. I created a file called validations.js
and put it in
.../xdocs/resources/scripts and made sure in the forrest.properties file
that resources is mapped.

in the page I have <script type="text/javascript"
src="/resources/scripts/valdiations.js" /> between the header tags.


My scripts work outside of forrest in standard html pages, but I can not
get them to work using forrest, what am I doing wrong, and I can't find
a document to help me with it.

Thanks,
--------------------------------------------

Eric
Re: Newbie with some javascript questions [ In reply to ]
On 06/06/07, Lipsius, Eric M <eric.m.lipsius@lmco.com> wrote:
>
>
> I was looking at the FAQ on adding my own javascripts so I can use them on
> my forrest page

...

> in the page I have <script type="text/javascript"
> src="/resources/scripts/valdiations.js" /> between the
> header tags.

In the FAQ entry it says:

"Then refer to those from your source documents with URIs like
/skin/blah.js and /skin/foo.css"

compare the URI in the faq to the uri you are using.

Ross
RE: Newbie with some javascript questions [ In reply to ]
I have also tried placing them in the
src/documentation/skins/$skin-name/scripts directory

Well actually had to create the /skins/pelt/scripts directory myself and
tried accessing it from /skins/validations.js

But that does not work either. I tried looking at the resources.xmap to
understand it better but that did not help me.

This is how my code looks in my source file:

<document>
<header>
<title>Search Tools</title>
<script type=text/javascript" src="/skins/validations.js"/>
</header>
<body>
.....
</body>
</document>

Am I not calling it correctly?


------------
Eric
Re: Newbie with some javascript questions [ In reply to ]
Lipsius, Eric M wrote:
> This is how my code looks in my source file:
>
> <document>
> <header>
> <title>Search Tools</title>
> <script type=text/javascript" src="/skins/validations.js"/>
> </header>
> <body>
> .....
> </body>
> </document>
>
> Am I not calling it correctly?

XDoc has no script element. I don't recall at the moment how this is
done with skins. By looking at pelt's document-to-html stylesheet, it
looks like this element will be stripped implicitly. I don't think the
solution calls for a custom skin, but I don't remember the details. It
may be injected by skinconf.xml the way extra CSS is handled. With
skins, I think the solution applies to every document and is not handled
per document.

Brian
Re: Newbie with some javascript questions [ In reply to ]
On 06/06/07, Brian M Dube <bdube@apache.org> wrote:
> Lipsius, Eric M wrote:
> > This is how my code looks in my source file:
> >
> > <document>
> > <header>
> > <title>Search Tools</title>
> > <script type=text/javascript" src="/skins/validations.js"/>
> > </header>
> > <body>
> > .....
> > </body>
> > </document>
> >
> > Am I not calling it correctly?
>
> XDoc has no script element. I don't recall at the moment how this is
> done with skins. By looking at pelt's document-to-html stylesheet, it
> looks like this element will be stripped implicitly. I don't think the
> solution calls for a custom skin, but I don't remember the details. It
> may be injected by skinconf.xml the way extra CSS is handled. With
> skins, I think the solution applies to every document and is not handled
> per document.

Hmmm... that's interesting. Our FAQ clearly states that this is
possible, but it appears the FAQ entry is misleading. Brian is correct
that the script element is not allowed in our XDoc.

There has been some discussion in the past, in particular see [1]
(which interestingly enough was written by me, but it was a long time
ago so you'll forgive me for not remembering, I hope. Note that my
reference to forrest:views at the end should now be read as
"dispatcher" which is now pretty stable in the whiteboard and will
almost certainly be moving out sometime in the near(ish) future.

In [2] you will find a little more discussion from someone who tried,
but failed to get this working. Let us know if you too have help, but
please give plenty of details, most of us do not embed javascript in
out source so we'll be providing options and pointers rather than
direct answers.

It would be really helpful if you could provide us with a better
answer to the FAQ question once you have this nailed.

Ross

[1] http://www.mail-archive.com/user@forrest.apache.org/msg00993.html
[2] http://thread.gmane.org/gmane.text.xml.forrest.user/3703/focus=3709
Re: Newbie with some javascript questions [ In reply to ]
Ross Gardler wrote:
> Brian M Dube wrote:
> >Lipsius, Eric M wrote:
> >> This is how my code looks in my source file:
> >>
> >> <document>
> >> <header>
> >> <title>Search Tools</title>
> >> <script type=text/javascript" src="/skins/validations.js"/>
> >> </header>
> >> <body>
> >> .....
> >> </body>
> >> </document>
> >>
> >> Am I not calling it correctly?
> >
> >XDoc has no script element. I don't recall at the moment how this is
> >done with skins. By looking at pelt's document-to-html stylesheet, it
> >looks like this element will be stripped implicitly. I don't think the
> >solution calls for a custom skin, but I don't remember the details. It
> >may be injected by skinconf.xml the way extra CSS is handled. With
> >skins, I think the solution applies to every document and is not handled
> >per document.
>
> Hmmm... that's interesting. Our FAQ clearly states that this is
> possible, but it appears the FAQ entry is misleading. Brian is correct
> that the script element is not allowed in our XDoc.
>
> There has been some discussion in the past, in particular see [1]
> (which interestingly enough was written by me, but it was a long time
> ago so you'll forgive me for not remembering, I hope. Note that my
> reference to forrest:views at the end should now be read as
> "dispatcher" which is now pretty stable in the whiteboard and will
> almost certainly be moving out sometime in the near(ish) future.
>
> In [2] you will find a little more discussion from someone who tried,
> but failed to get this working. Let us know if you too have help, but
> please give plenty of details, most of us do not embed javascript in
> out source so we'll be providing options and pointers rather than
> direct answers.
>
> It would be really helpful if you could provide us with a better
> answer to the FAQ question once you have this nailed.
>
> Ross
>
> [1] http://www.mail-archive.com/user@forrest.apache.org/msg00993.html
> [2] http://thread.gmane.org/gmane.text.xml.forrest.user/3703/focus=3709

There is a way to do it using xdoc source format.
Add a "<script ..." to the body element and disable
validation of these xml sources. It is cheating
but it should work.

Another way might be to intercept the xml pipeline
and add another transformation to inject the extra
"<script ..." element.

Our internal format is not being validated, so it
should be able to be overloaded with extra elements.

Another way is to hack the pelt skin and explicitly
add the "<script ..." to the html output.

As Brian said above, we could add a basic solution
by doing something similar to "extra-css" in skinconf.

None of these solutions are ideal. Hence Dispatcher.

-David