I have created a composite component in JSF2. I works great.
I would like to create it as JAR for future use.
I followed the instructions here.
However, when it comes to CSS the browser refers to the location relatively to the project that uses the jar and not to the Jar location!
I defined it like this:
<h:outputStylesheet library="css" name="component.css" target="head" />
and I get this exception: GET http://localhost:8080/MY_APPLICATION/resources/component.css 404 (Not Found)
It's looking for it relatively to the projects, and not to the Jar project!
How can I make it relative to the JAR project?
EDITED
The JAR tree is:
META-INF
--resource
-- components
myComp.xhtml
components.css
-- img
-- scripts
--components.taglib.xml
--faces.config.xml
The war is a regular dynamic project:
WEB-INF
--lib
myJar.jar
-- web.xml
-- faces-config.xml
testComp.xhtml
Your JAR directory structure should be:
META-INF
--resources
-- components
myComp.xhtml
-- css <-- The library defined in the stylesheet
components.css <-- A stylesheet resource in the library
-- img
-- scripts
--components.taglib.xml
--faces.config.xml
Since, you are specifying the library name as css in the h:outputStylesheet tag with the resource name as component.css, the file should be present in a directory named css located in META-INF/resources directory of the JAR file.
Also, consider using a library name that is not bound to conflict with other names, if you intend to allow other developers to use your JAR.
AFAIK, the resource needs to be located in the same directory as the composite component. Have you tried to put the css in the same library?
Related
I am using the Play! Framework ( 2.6.2 ), Scala ( 2.12.2 ) and trying to integrate LESS into it.
I was using this tutorial on their documentation website.
In my build.sbt file this is the code in place:
lazy val root = (project in file(".")).enablePlugins(PlayJava, PlayEbean, SbtWeb)
includeFilter in (Assets, LessKeys.less) := "*.less"
excludeFilter in (Assets, LessKeys.less) := "_*.less"
LessKeys.compress in Assets := true
And in my plugin.sbt file I've added:
addSbtPlugin("com.typesafe.sbt" % "sbt-less" % "1.1.2")
I've got 2 files with .less extention. main.less and login.less in a /css folder under /public directory.
When I compile and run the project in my target folder the files stay as .less files and don't get compiled into .css files.
In my HTML template code I have this line:
<link rel="stylesheet" media="screen" href="#routes.Assets.versioned("css/login.css")">
The link to the stylesheet works if I change the extention from login.less to login.css but the variables don't seem to be accessible in the login.less file.
The link to the stylesheet doesn't work with the .css extention as expected because the framework doesn't seem to be compiling the files to .css, it just seems to leave them as .less files. Therefore I'm just getting a 404 on the .css file. If i change the extention in the link to .less it then works fine but variables I've imported from main.less to login.less don't work.
Is there a step I'm missing? Can somebody explain why the framework would not compile the .less files to .css files in my target folder?
EDIT 1: After trying the fix suggested by #marcospereira: I think the application is trying to compile both files but also returns me an error and application doesn't run at all.
[info] LESS compiling on 2 source(s)
-------
Unexpected exception
JsTaskFailure: java.lang.NoSuchMethodError: org.mozilla.javascript.ScriptRuntime.setObjectProp(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;Lorg/mozilla/javascript/Context;Lorg/mozilla/javascript/Scriptable;)Ljava/lang/Object;
at io.apigee.trireme.node10.main.trireme._c_anonymous_1(trireme.js:37)
at io.apigee.trireme.node10.main.trireme.call(trireme.js)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:394)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3102)
at io.apigee.trireme.node10.main.trireme.call(trireme.js)
at io.apigee.trireme.core.internal.ScriptRunner.runScript(ScriptRunner.java:762)
at io.apigee.trireme.core.internal.ScriptRunner$4.run(ScriptRunner.java:702)
at org.mozilla.javascript.Context.call(Context.java:488)
at org.mozilla.javascript.ContextFactory.call(ContextFactory.java:504)
at io.apigee.trireme.core.internal.ScriptRunner.call(ScriptRunner.java:697)
at io.apigee.trireme.core.ScriptFuture.run(ScriptFuture.java:183)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
-------
You need to install node.js on your machine.
If you do not have node.js installed then it will fall back to the Trireme Java-based JavaScript engine, which does not work very well and is resulting in that error
Managed assets needs to be inside app/assets. From the docs:
Compilable assets in Play must be defined in the app/assets directory. They are handled by the build process, and LESS sources are compiled into standard CSS files. The generated CSS files are distributed as standard resources into the same public/ folder as the unmanaged assets, meaning that there is no difference in the way you use them once compiled.
So, you need to move your files from public/css to app/assets/css.
I want to remove some of the configuration from the Alfresco Share web.xml. That file lives at $TOMCAT_HOME/webapps/share/WEB-INF/web.xml so I added the customized file to $AMP_FOLDER/_share/config/META-INF/WEB-INF/web.xml. The WEB-INF folder lives at the same level as other customizations - compentents and css - which get mapped to the share.war correctly. The web.xml file appears to just get ignored though (find $TOMCAT_HOME/webapps/share -name web.xml only finds the old version of the file).
How do I tell the amp file where to put the web.xml file?
All the documentation I have found says to not override the web.xml file, but I need to remove some of the filters that are being applied.
Use -force parameter when running the apply amps and don't put your web.xml in WEB-INF because mmt ignores that.
Use for example in the file-mapping.properties:
/web/WEB-INF=/WEB-INF
and
java -jar alfresco-mmt.jar install <AMPFileLocation> <WARFileLocation> -force
I'm using the NodeJS implementation of KSS. I have the following file structure:
sass (.scss files)
css (compiled .css files)
images (images & sprites)
styleguide (auto-generated styleguide html)
|- public (auto-generated assets)
|- template (styleguide template files)
I can successfully generate a styleguide by executing the following command line instruction:
kss-node sass styleguide --css css/styles.css --template styleguide/template
So sass is my source folder to parse, styleguide is the destination folder and the --css and --template options tell the compiler where to find my main css file and template respectively. During the process the contents of the css/styles.css file is copied over to styleguide/public/style.css which is then referenced by the styleguide. This is all great.
However, the css file that is generated and referenced by the styleguide now sits in a different folder structure from the original css file (it is two deep from the root instead of one) and therefore any references to the images folder are now invalid. Is there a way to resolve this without placing my original css files in another folder in the css directory to mimic the styleguide folder structure (which would be a massive hack)?
Also, any other references to images in the normal html markup (derived from the scss comments) will have to be adapted to reference the adjusted folder structure, and therefore is not indicative of a real life implementation of my code. Is there a way to resolve this too?
Thanks
I know it's not a solution per se, but what I ended up doing was a Grunt task to copy my images (even the generated by Compass) to the public folder of the generated styleguide after the KSS parsing (also done with Grunt).
In the manifest file for an eclipse plugin its possible to add jar files and
folders to the classpath (on the Runtime tab).
In the root of my plugin I have a folder lib containing a-1.0.1.jar, b-1.0.0-SNAPSHOT.jar. But only when I select each jar separately:
Bundle-ClassPath: .,
lib/a-1.0.1.jar,
lib/b-1.0.0-SNAPSHOT.jar
...can they be used inside my project. Why is it not possible to add them to the classpath by adding the common root folder only:
Bundle-ClassPath: .,
lib/
?
No, you can't. Eclipse is based on OSGi, which is the platform providing MANIFEST.MF support to build plugins.
When you set values under Bundle-ClassPath, OSGi search into each one to find class files. So you can put folders containing Java packages and class files. When you put a jar file, it is uncompressed in memory and viewed by OSGi as a regular folder, still searching for class files.
Unfortunately, there is no way to load all jar from a folder. No wildcard mechanism or something like that is allowed here.
I am trying to create a jar file which includes some class and java files needed, but I also would like to include some extra xml, xsl, html, txt (README) files.
I am using Eclipse on Windows XP.
Is there an easy way for me to set up a directory structure and package all my files into a jar?
Add the files to a source folder and they can be included in the jar.
One common way is to have, at the root of your project, a src folder. Within that, folders for java files, and others. something like:
src/
css/
java/
html/
images/
Then you can make each of those subfolders a source folder (Right click, Use as Source Folder) and they should be available to add to the jar.
A .jar is nothing but a ZIP archive, so you can use any program capable of creating ZIPs. Just make sure that you include the manifest and all the class files.
I just added all the files into my Eclipse project (including the txt, html, xml, etc files).
Then I used Eclipse to File->Export->Jar File->Next
Check the "Export Java source files and resources" box.
Done.
If you're using Ant, you can use the jar task (see the examples section for how to include/exclude certain files, etc.)
If you move to an ANT (or Maven, for you Maven fans) then you can automate the Jar building very nicely, and also use it outside of Eclipse (e.g., in an automated build environment). All you need to do is copy the files from your src, jsp, foobar and resources locations into a build staging folder, then Jar the resulting files using ANT's Jar task.
<target name="makejar" depends="compile, copyfiles">
<jar destfile="${jars.dir}/myjarfile.jar" index="true" basedir="${build.dir}" />
</target>
One thing I look down on is including non-source (except package.html files for Javadoc) within the src folder. If you feel you have to do this to achieve something, then you are doing it wrong.