How to prevent loading of Richfaces 4 component css files - jsf

I'm upgrading from Richfaces 3.3 to 4.
I have a number of custom css files and skins.
Richfaces 4 seems to have added a whole load of new classes to various components i.e. rf-tab, rf-tab-cnt, etc.
These components have styles associated with them (They appear to be loaded in ecss file with names like panel.ecss, datascroller.ecss, etc)
They have really messed up my current UI layout :(
Is there any way to disable the loading of all these component stylessheets?
I tried applying the following but it does not work:
<context-param>
<param-name>org.richfaces.LoadStyleStrategy</param-name>
<param-value>NONE</param-value>
</context-param>
<context-param>
<param-name>org.ajax4jsf.COMPRESS_STYLE</param-name>
<param-value>false</param-value>
</context-param>
Thanks

Use 'plain' skin. This way most CSS classes will be rendered but not defined...

Related

My js/css caching is not working even after using project stage and filters, header date always getting update

I am trying to implement caching for my JS/CSS files but it is not working, I am using Mojarra JSF-2.2.12 and PrimeFaces 6.
I have tried using javax.faces.PROJECT_STAGE as Production and created a custom filter but nothing worked.
Need your help... below is web.xml code snippet
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Production</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.defaultResourceMaxAge</param-name>
<param-value>3628800000</param-value> <!-- 8 hours -->
</context-param>
In xhtml we have written like below.
<h:outputScript name="js/ProcessSpecific-min.js"></h:outputScript>
It looks like response server header is updating date and time on every hit, may be that is the reason it is not able to pick it from cache.
header response for 1 file
you use Mojarra or Myfaces ?
In Mojarra you can control the expiration time by the following context parameter (the value is in millis):
<context-param>
<param-name>com.sun.faces.defaultResourceMaxAge</param-name>
<param-value>3628800000</param-value> <!-- 6 weeks. -->
</context-param>
And in MyFaces:
<context-param>
<param-name>org.apache.myfaces.RESOURCE_MAX_TIME_EXPIRES</param-name>
<param-value>3628800000</param-value> <!-- 6 weeks. -->
</context-param>
Set HTTP headers properly to force caching on JS, CSS and PNG files

Java EE + JSF url mappings

I can't find in Internet any good explanation of mapping URLs in Java EE with JSF + managed bean (Yes - I know, that there are ten million of tutorials, but after reviewing first million with HelloWorld page I resigned of reading rest of them..).
Before reading about Java EE + JSF I was working with Spring + JSP project, where URL mapping was made with annotations #GET/#POST etc in controllers, with url as attribute - very easy solution with one method per one URL with putting resources to response page with method. (I don't know how it was made in background - I'm beginner, but solution was very easy :) )
Now I read a book about Java EE, there was something about mapping in web.xml file, but it was very unclear. I feel, that there is other thinking - JSF page while needs to be rendered is connecting to managed bean to obtain needed values. But how is the mapping done here?
It's probably not clean, so I'll explain with my sample.
I have the following structure of project
I want, that pages customerdetails.xhtml and customers.xhtml could be read with url localhost:8080/P1WSClient/customerdetails.xhtml and customers.xhtml respectively.
I've done the following web.xml configuration:
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<servlet>
<servlet-name>Customers servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Customers servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
</web-app>
Ok, It's working. But how to make for example, when I want to make page customer to be loaded on default location localhost:8080/P1WSClient/ , or clients loaded on location localhost:8080/P1WSClient/something1/something2/mypage.html?
Other cuestion - why at the beginning url pattern is ´/faces/*.jsp´ and ´/faces/index/hxtml´? And index is being loaded on default url.. I don't get it!
Other cuestion - what is the thinging here - one ManagedBean per one page, or per one entity or.. ??
I can't find any good sample or tutorial, which could explain the urls mapping for many pages and many urls structure. If someone can explain mechanism of mapping in Java EE projects, please add it here. Any diagrams of mapping recognize with connection with managed beans and jsp inside app are also welcome :-)
If you want to change the default page (which is seen at localhost:8080/P1WSClient/) change the welcome file option in web.xml
<welcome-file-list>
<welcome-file>customers.xhtml</welcome-file>
</welcome-file-list>
If you want to reach a page under some directory, create folder in web-pages folder.
localhost:8080/P1WSClient/something1/something2/mypage.html
-Web Pages
--something1
----something2
-------mypage.xhtml
JSF requests go to the JSF servlet, which is the one in charge of locating the XHTML file, processing it and do the "work".
Sometimes the servlet is mapped to the all the URLs that end in .xhtml, other times only to the .xhtml URLs in a subdirectory. Of course, only requests that are mapped will be processed (if you have mapped the servlet to /faces/*.xhtml and you get a request for /myFiles/index.xhtml, the container will return index.xhtml as an static resource. As you understand, it could be any path, faces is just more usual.
I am not sure if how you can get the "redirect to some file if the URL does not specify one". I would try a Filter.
And for managed beans, it depends. Usually I am using one for the data and one for the controller of each page (data usually #ViewScoped, controller most times #RequestScoped), plus additional beans when needed for composite components.

Applying Theme in Primefaces 5.1 via primefaces.THEME doesn't work

I am trying to get the downloaded Dark-Hive Themeroller theme for a PrimeFaces project going but can't figure out why it won't show...Looking into the html source code I always see Aristo theme, which I believe is the default PrimeFaces theme. I followed multiple forum suggestions but have to post this one into the community - maybe someone can give me a hint.
Project structure:
/webapp/WEB-INF/lib/dark-hive.jar -> downloaded from themeroller.org
and converted with themeroller.osnode.com/themeroller into a PF
theme
/webapp/WEB-INF/templates/layout.xhtml -> my master template, which contains xmlns:h="http://java.sun.com/jsf/html" namespace attribute as well as tag
/webapp/WEB-INF/resources
/webapp/WEB-INF/web.xml
/webapp/WEB-INF/faces-config.xml
...
I don't output any CSS simply because according to the docs it's not needed for PF themes to work.
Parts of web.xml:
<context-param>
<param-name>javax.faces.WEBAPP_RESOURCES_DIRECTORY</param-name>
<param-value>/WEB-INF/resources</param-value>
</context-param>
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>dark-hive</param-value>
</context-param>
Please note that I moved the resources folder into WEB-INF/.
Parts of pom.xml:
<dependency>
<groupId>org.primefaces.themes</groupId>
<artifactId>dark-hive</artifactId>
<version>1.0.8</version>
</dependency>
Because of Maven dependency and manual download/drop into /WEB-INF/lib folder I now have 2 dark-hive.jar in my war file:
/WEB-INF/lib/dark-hive-1.0.8.jar
/WEB-INF/lib/dark-hive.jar
Both have the same internal structure.
I am using WildFly 8.1.0.Final with upgraded JSF Mojarra 2.2.8, PrimeFaces 5.1, OmniFaces 1.8.1
Any ideas?
The answer lies within the use of OmniFaces showcase HeadRenderer.
In my faces-config.xml I was using:
<render-kit>
<renderer>
<component-family>javax.faces.Output</component-family>
<renderer-type>javax.faces.Head</renderer-type>
<renderer-class>org.omnifaces.showcase.HeadRenderer</renderer-class>
</renderer>
</render-kit>
which used the primefaces-aristo theme.
Solution was to write my own HeadRenderer according to:
Custom HeadRenderer

Primefaces Style Doens't work correctly

I started a JSF project and included primefaces. But I have problems with the style. It doesn't look that nice than in the official showcase. But I have no idea why.
That's what I did so far:
I downloaded a style and extracted it into my project.
I added <link type="text/css" rel="stylesheet" href="#{request.contextPath}/resources/flick/skin.css" /> to my facelets template
I extended my web.xml with the following:
<context-param>
<param-name>primefaces.skin</param-name>
<param-value>none</param-value>
</context-param>
Unfortunately it loks like that:
fyi: That's a prime panel and a prime button :-/
can you pls help me :-)
cheers
Update:
Whatsoever I change in context-param. it doesn't work!
Do you need more information to help me solve that problem?
Thank you for help..
That's becuase you used none skin.
Look in Prime different skins to choose the right skin.
For example, if you would like Eggplant add:
<context-param>
<param-name>primefaces.skin</param-name>
<param-value>Eggplant</param-value>
</context-param>
I switched from myfaces to mojarra and now it works -.-

JSF 1.1 and tomahawk 1.1.1 inputCalendar, is myfaces-*.jar needed?

I should use JSF 1.1 Mojarra implemetnation in job project.
But I need a popUp calendar widget. I've tried many different frameworks and stopped on tomahawk. I've setupped filter for tomahawk javasripts in web.xml but still have problems.
Should I necessary replace jsf-impl.jar and jsf-api.jar with myfaces-impl.jar and myfaces-api.jar ?
Or can I work with some versions of tomahawk calendar without faces.jar ?
Maybe someone can advice some popup calendar widget for JSF 1.1 from other frameworks that can be easy integrated?
Should I necessary replace jsf-impl.jar and jsf-api.jar with myfaces-impl.jar and myfaces-api.jar ?
No, that's not needed. Tomahawk is just a component library which is supposed to be JSF implementation independent. That it is created by the MyFaces guys is pure coincidence. I've used Tomahawk on Mojarra for ages and it works fine.
You should be more clear about those "problems" if you want more assistance. Ask a new question wherein you post the problem in depth detail (JSF/Tomahawk/Servletcontainer impl/version, steps done, unexpected results, any warnings/errors/exceptions, etc).
If you just need a date picker, you could use the pure javascript library, eg: http://www.nsftools.com/tips/DatePickerTest.htm
Seams that this combination works with JSF 1.1 Mojarra implementations:
commons-fileupload-1.2.2.jar
tomahawk-1.1.9.jar
And changes in web.xml:
<filter>
<filter-name>extensionsFilter</filter-name>
<filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
</filter>
<!--
extension mapping for adding <script/>, <link/>, and other resource
tags to JSF-pages
-->
<filter-mapping>
<filter-name>extensionsFilter</filter-name>
<servlet-name>Faces Servlet</servlet-name>
</filter-mapping>
<!--
extension mapping for serving page-independent resources (javascript,
stylesheets, images, etc.)
-->
<filter-mapping>
<filter-name>extensionsFilter</filter-name>
<url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
</filter-mapping>

Resources