You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Hendrik Neumann <th...@googlemail.com> on 2006/01/20 15:04:41 UTC

Best Pratice to serve JavaScript-files from JAR-files?

Hi List,

I have developed a bunch of JSF-Components which uses some
JavaScript-Codes (about 10 *.js-files). Now I have written an Apache
Maven Script which builds a mycomponents.jar file (containing
everything needed to use the components) which can simply be copied
into the lib-Folder of any other web-application.

My problem: This jar-file contains my javascript-files but what is the
most compfortable way to serve the script-files to the
client-browsers? How do you MyFaces-guys solve this problem? What
would be the best way to do it?

--
Mit freundlichen Grüßen / Greetings,
Hendrik Neumann; Ruhr-University of Bochum

Re: Best Pratice to serve JavaScript-files from JAR-files?

Posted by Hendrik Neumann <th...@googlemail.com>.
>  Please make sure to provide feedback on users@weblets.dev.java.net once
> you've had the chance to use Weblets in your own Faces component library.
> Some enhancements have already been filed, but we are always keen to
> understand additional usecases.

Yes - I already started to develop an equal project (I called it
"ResourceProvider") and I had a lot of ideas about cool features. But
I stoped it 'cause I currently have a lot of work to do.  I'll check
out what of this features Weblets  can do and what it can not do and
then I'll give you some feedback!

Re: Best Pratice to serve JavaScript-files from JAR-files?

Posted by Hendrik Neumann <th...@googlemail.com>.
>  Btw, since this is the MyFaces users list, it might be better to follow up
> on the Weblets users list instead. ;-)

done!

Re: Best Pratice to serve JavaScript-files from JAR-files?

Posted by John Fallows <jo...@gmail.com>.
Hi Hendrik,

We'd need to see the contents of your weblets-config.xml file and the usage
from the Renderer via the weblet:// pseudo-protocol.

Btw, since this is the MyFaces users list, it might be better to follow up
on the Weblets users list instead. ;-)

users@weblets.dev.java.net

Kind Regards,
John Fallows.

On 1/21/06, Hendrik Neumann <th...@googlemail.com> wrote:
>
> >  Please make sure to provide feedback on users@weblets.dev.java.net once
> > you've had the chance to use Weblets in your own Faces component
> library.
> > Some enhancements have already been filed, but we are always keen to
> > understand additional usecases.
>
> I can't get it to work! I copied the weblets.jar in my JSF-Component
> project. Created a weblets-config.xml which will be placed in the
> META-INF folder of my jsfcomponent.jar. Then I changed my component
> renderer to give me a "hello world" javascript alert using the
> getResourceURL and your weblet-protocoll. Finally I copied the
> weblets.jar and jsfcomponent.jar into an existing
> MyFaces-Test-Application but the screen-rendering crashes.
>
> But tomcat error log gives me a "net.java.dev.weblets.WebletException:
> Missing Weblet configuration for 'application'" but the configuration
> in /META-INF/weblets-config.xml and the getResourceURL-parameter do
> match.
>
> What am I doing wrong? It's not working ;-(
>



--
http://apress.com/book/bookDisplay.html?bID=10044
Author: Pro JSF and Ajax: Building Rich Internet Components, Apress

Re: Best Pratice to serve JavaScript-files from JAR-files?

Posted by Hendrik Neumann <th...@googlemail.com>.
>  Please make sure to provide feedback on users@weblets.dev.java.net once
> you've had the chance to use Weblets in your own Faces component library.
> Some enhancements have already been filed, but we are always keen to
> understand additional usecases.

I can't get it to work! I copied the weblets.jar in my JSF-Component
project. Created a weblets-config.xml which will be placed in the
META-INF folder of my jsfcomponent.jar. Then I changed my component
renderer to give me a "hello world" javascript alert using the
getResourceURL and your weblet-protocoll. Finally I copied the
weblets.jar and jsfcomponent.jar into an existing
MyFaces-Test-Application but the screen-rendering crashes.

But tomcat error log gives me a "net.java.dev.weblets.WebletException:
Missing Weblet configuration for 'application'" but the configuration
in /META-INF/weblets-config.xml and the getResourceURL-parameter do
match.

What am I doing wrong? It's not working ;-(

Re: Best Pratice to serve JavaScript-files from JAR-files?

Posted by John Fallows <jo...@gmail.com>.
Hi Hendrik,

On 1/20/06, Hendrik Neumann <th...@googlemail.com> wrote:
>
> Thanks a lot Martin! According to the description of the project it
> seems to be exactly the solution I was looking for!


Happy to help. ;-)

Please make sure to provide feedback on users@weblets.dev.java.net once
you've had the chance to use Weblets in your own Faces component library.
Some enhancements have already been filed, but we are always keen to
understand additional usecases.

Kind Regards,
John Fallows.
--
http://apress.com/book/bookDisplay.html?bID=10044
Author: Pro JSF and Ajax: Building Rich Internet Components, Apress

Re: Best Pratice to serve JavaScript-files from JAR-files?

Posted by Hendrik Neumann <th...@googlemail.com>.
Thanks a lot Martin! According to the description of the project it
seems to be exactly the solution I was looking for!

2006/1/20, Martin Marinschek <ma...@gmail.com>:
> John Fallow's weblets project might be the way to go for you.
>
> https://weblets.dev.java.net/
>
> regards,
>
> Martin
>
>
> On 1/20/06, Hendrik Neumann <th...@googlemail.com> wrote:
> > Hi List,
> >
> > I have developed a bunch of JSF-Components which uses some
> > JavaScript-Codes (about 10 *.js-files). Now I have written an Apache
> > Maven Script which builds a mycomponents.jar file (containing
> > everything needed to use the components) which can simply be copied
> > into the lib-Folder of any other web-application.
> >
> > My problem: This jar-file contains my javascript-files but what is the
> > most compfortable way to serve the script-files to the
> > client-browsers? How do you MyFaces-guys solve this problem? What
> > would be the best way to do it?
> >
> > --
> > Mit freundlichen Grüßen / Greetings,
> > Hendrik Neumann; Ruhr-University of Bochum
> >
>
>
> --
>
> http://www.irian.at
>
> Your JSF powerhouse -
> JSF Consulting, Development and
> Courses in English and German
>
> Professional Support for Apache MyFaces
>


--
Mit freundlichen Grüßen / Greetings,
Hendrik Neumann; Ruhr-University of Bochum

Re: Best Pratice to serve JavaScript-files from JAR-files?

Posted by Martin Marinschek <ma...@gmail.com>.
John Fallow's weblets project might be the way to go for you.

https://weblets.dev.java.net/

regards,

Martin


On 1/20/06, Hendrik Neumann <th...@googlemail.com> wrote:
> Hi List,
>
> I have developed a bunch of JSF-Components which uses some
> JavaScript-Codes (about 10 *.js-files). Now I have written an Apache
> Maven Script which builds a mycomponents.jar file (containing
> everything needed to use the components) which can simply be copied
> into the lib-Folder of any other web-application.
>
> My problem: This jar-file contains my javascript-files but what is the
> most compfortable way to serve the script-files to the
> client-browsers? How do you MyFaces-guys solve this problem? What
> would be the best way to do it?
>
> --
> Mit freundlichen Grüßen / Greetings,
> Hendrik Neumann; Ruhr-University of Bochum
>


--

http://www.irian.at

Your JSF powerhouse -
JSF Consulting, Development and
Courses in English and German

Professional Support for Apache MyFaces

Re: Best Pratice to serve JavaScript-files from JAR-files?

Posted by Hendrik Neumann <th...@googlemail.com>.
2006/1/20, Simon Kitching <sk...@apache.org>:
> On Fri, 2006-01-20 at 14:04 +0000, Hendrik Neumann wrote:
> > Hi List,
> >
> > I have developed a bunch of JSF-Components which uses some
> > JavaScript-Codes (about 10 *.js-files). Now I have written an Apache
> > Maven Script which builds a mycomponents.jar file (containing
> > everything needed to use the components) which can simply be copied
> > into the lib-Folder of any other web-application.
> >
> > My problem: This jar-file contains my javascript-files but what is the
> > most compfortable way to serve the script-files to the
> > client-browsers? How do you MyFaces-guys solve this problem? What
> > would be the best way to do it?
>
> This problem needs no solution for core JSF components because none of
> them require complicated script; any script used is inline.
>
> It's solved in Tomahawk via the AddResources and ExtensionsFilter
> classes working in partnership. Classes call AddResources to "queue"
> script references needed in the page; the ExtensionsFilter buffers the
> entire page output and calls back into AddResources when the page is
> complete to allow that class to insert the queued references into the
> appropriate parts of the html page via a special URL
> "{contextPath}/faces/myFacesExtensionResource/..." which must also be
> mapped to the ExtensionsFilter. This then locates the desired file
> within the classpath and serves it up.
>
> The javadoc on org.apache.myfaces.component.html.util.AddResource
> describes how this works in detail.
>
> ExtensionsFilter has javadoc but there is also info here:
>   http://myfaces.apache.org/tomahawk/extensionsFilter.html
>
> Regards,
>
> Simon
>
>

thanks for your help - I'll also take a look at this! I already
noticed this AddResources and ExtensionsFilter classes by analyzing
your source code...

Re: Best Pratice to serve JavaScript-files from JAR-files?

Posted by Simon Kitching <sk...@apache.org>.
On Fri, 2006-01-20 at 14:04 +0000, Hendrik Neumann wrote:
> Hi List,
> 
> I have developed a bunch of JSF-Components which uses some
> JavaScript-Codes (about 10 *.js-files). Now I have written an Apache
> Maven Script which builds a mycomponents.jar file (containing
> everything needed to use the components) which can simply be copied
> into the lib-Folder of any other web-application.
> 
> My problem: This jar-file contains my javascript-files but what is the
> most compfortable way to serve the script-files to the
> client-browsers? How do you MyFaces-guys solve this problem? What
> would be the best way to do it?

This problem needs no solution for core JSF components because none of
them require complicated script; any script used is inline.

It's solved in Tomahawk via the AddResources and ExtensionsFilter
classes working in partnership. Classes call AddResources to "queue"
script references needed in the page; the ExtensionsFilter buffers the
entire page output and calls back into AddResources when the page is
complete to allow that class to insert the queued references into the
appropriate parts of the html page via a special URL
"{contextPath}/faces/myFacesExtensionResource/..." which must also be
mapped to the ExtensionsFilter. This then locates the desired file
within the classpath and serves it up.

The javadoc on org.apache.myfaces.component.html.util.AddResource
describes how this works in detail.

ExtensionsFilter has javadoc but there is also info here:
  http://myfaces.apache.org/tomahawk/extensionsFilter.html

Regards,

Simon