JSF 2.0 composite component into jar - jar

I'm trying create a composite component to use across my projects, so, I've created a project called "componentes-ui-web" and putted 2 xhtml files that are my components.
The structure of the project is like this:
src
> |-> main
> > |->java
> > |->META-INF
> > |->faces-config.xml
> > |->resources
> > |->componentes
> > |->popupSimples.xhtml
> > |->popupSubmit.xhtml
This is the code of popupSubmit.xhtml:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:icecore="http://www.icefaces.org/icefaces/core"
xmlns:ice="http://www.icesoft.com/icefaces/component"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:composite="http://java.sun.com/jsf/composite"
xmlns:ace="http://www.icefaces.org/icefaces/components">
<composite:interface>
<composite:attribute name="modal" default="false" />
<composite:attribute name="visivel" default="false" />
<composite:attribute name="style" default="" />
<composite:attribute name="titulo" default="Sem título definido" />
<composite:attribute name="exibidoQuandoTipoUsuario" default="" />
<composite:attribute name="metodoFechar"
method-signature="java.lang.Void fechar()" required="true" />
<composite:attribute name="metodoSubmeter"
method-signature="java.lang.Void submeter()" required="true" />
<composite:facet name="conteudo" />
</composite:interface>
<composite:implementation>
<h:form>
<ice:panelPopup modal="#{cc.attrs.modal}"
renderedOnUserRole="#{cc.attrs.exibidoQuandoTipoUsuario}"
draggable="#{cc.attrs.modal}" rendered="#{cc.attrs.visivel}"
clientOnly="true" autoCentre="true" style="#{cc.attrs.style}">
<f:facet name="header">
<ui:insert name="barraDeTitulos">
<ice:panelLayout layout="flow" style="width:100%">
<h:outputText value="#{cc.attrs.titulo}" style="float:left" />
<h:commandLink value="[X]" style="float:right"
action="#{cc.attrs.metodoFechar}" immediate="true" />
</ice:panelLayout>
</ui:insert>
</f:facet>
<f:facet name="body">
<ice:panelLayout layout="flow" style="width:100%">
<composite:renderFacet name="conteudo" />
<ui:insert name="barraDeBotoes">
<ice:panelLayout layout="flow">
<ace:pushButton value="CANCELAR" immediate="true"
style="float:right" action="#{cc.attrs.metodoFechar}" />
<ace:pushButton value="OK" style="float:right"
action="#{cc.attrs.metodoSubmeter}" />
</ice:panelLayout>
</ui:insert>
</ice:panelLayout>
</f:facet>
</ice:panelPopup>
</h:form>
</composite:implementation>
</html>
In another Web project I try to use this component simply adding that jar to the lib (maven) and adding the tag:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:icecore="http://www.icefaces.org/icefaces/core"
xmlns:ice="http://www.icesoft.com/icefaces/component"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:hrgi="http://java.sun.com/jsf/composite/componentes"
xmlns:ace="http://www.icefaces.org/icefaces/components">
<ui:component>
<f:loadBundle basename="com.hrgi.web.configuracoes.messages"
var="configuracoesMsg" />
<hrgi:popupSubmit modal="true" visivel="true"
titulo="#{configuracoesMsg['popup.importador_nfe.titulo']}"
exibidoQuandoTipoUsuario="ROLE_ADMINISTRADOR"
metodoFechar="#{controladorPopupConfiguracaoImportadorNFe.fechar}"
metodoSubmeter="#{controladorPopupConfiguracaoImportadorNFe.submeter}">
<f:facet name="conteudo">
...
</hrgi:popupSubmit>
</ui:component>
</html>
When I run the application, the component isn't shown and I receive this message in the firefox:
Warning: This page calls for XML namespace http://java.sun.com/jsf/composite/componentes declared with prefix hrgi but no taglibrary exists for that namespace.
What I did wrong??
Update thanks for the replies and sorry for the late to answer...
I've created the ResourceResolver like BalusC told, but without success.
I've checked the output of tomcat too, but didn't find any error.
This is my web.xml file, perhaps someone can find anything that could help me.
I will search about ResourceHandler too.
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<display-name>teste-zk</display-name>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
<url-pattern>/icefaces/*</url-pattern>
</servlet-mapping>
<context-param>
<param-name>javax.faces.FACELETS_RESOURCE_RESOLVER</param-name>
<param-value>com.hrgi.web.ui.FaceletsResourceResolver</param-value>
</context-param>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<context-param>
<param-name>com.sun.faces.enableMissingResourceLibraryDetection</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<context-param>
<param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>javax.faces.VALIDATE_EMPTY_FIELDS</param-name>
<param-value>false</param-value>
</context-param>
<servlet>
<servlet-name>Resource Servlet</servlet-name>
<servlet-class>com.icesoft.faces.webapp.CompatResourceServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Resource Servlet</servlet-name>
<url-pattern>/xmlhttp/*</url-pattern>
</servlet-mapping>
</web-app>

I've solved the problem. I've looked inside the jar file and didn't see the META-INF/resources folder with the xhtml files. So I changed the META-INF folder from src/main/java to src/main/resources. It worked

You should check if the ResourceHandler installed can locate the library and resource (popupSubmit.xhtml) inside you JAR file. Use a ResourceResolver will not help, because it is used for facelets (ui:xxx and facelet views). If there is some ResourceHandler wrapper that prevents locate the library and the resource, or some other problem on the classpath, it is expected the warning you are looking can be seen.

Related

No WebApplicationContext found: not in a DispatcherServlet request and no ContextLoaderListener registered

I am trying to write a spring MVC application and I am getting the below error
Code:
web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>Nov29thSpringMVC</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>nov</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>nov</servlet-name>
<url-pattern>*.htm</url-pattern>
</servlet-mapping>
</web-app>
nov-servlet.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=" http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="com.searchsme.controller" />
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix">
<value>/</value>
</property>
<property name="suffix">
<value>.jsp</value>
</property>
</bean>
</beans>
index.jsp
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%# taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<form:form id="searchSME" modelAttribute="searchSME" action="search" method="post">
<table align="center">
<tr>
<td>
<form:label path="username">Search SME: </form:label>
</td>
<td>
<form:input path="search" name="searchTopic" id="searchTopic" />
</td>
</tr>
<tr>
<td></td>
<td align="left">
<form:button id="login" name="login">Search</form:button>
</td>
</tr>
<tr></tr>
</table>
</form:form>
</body>
</html>
error:
java.lang.IllegalStateException: No WebApplicationContext found: not in a DispatcherServlet request and no ContextLoaderListener registered?
I saw some old posts and tried below it did not work and it
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
I am getting the below exception
Caused by: java.io.FileNotFoundException: Could not open
ServletContext resource [/WEB-INF/applicationContext.xml]
Do we have to write applicationContext.xml as well? I already have the configaration file.
Hello Please add your web.xml and no-servlet.xml in WEB-INF and try below code. for dispatcher servlet.
<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/nov-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
it is mandatory to have it in same folder if u using maven project u can take file from resource folder by passing parameter to init-param as
classpath:config-file-name.xml

Tomcat 404 Http Not Found

I am learning Spring MVC and I build the first "hello world" example. But I can not reach the page. It says "The origin server did not find a current representation for the target resource or is not willing to disclose that one exists." I am using Tocat 9.0 (I also tried Tomcat 8 still not working). So here is my code below
Controller:
package com.emin.springdemo.mvc;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
#Controller
public class HomeController {
#RequestMapping("/")
public String showPage() {
return "main-menu";
}
}
jsp file:
<%# page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Insert title here</title>
</head>
<body>
<h2>Spring MVC Demo</h2>
</body>
</html>
servlet.xml:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<!-- Step 3: Add support for component scanning -->
<context:component-scan base-package="com.emin.springdemo.mvc" />
<!-- Step 4: Add support for conversion, formatting and validation support -->
<mvc:annotation-driven/>
<!-- Step 5: Define Spring MVC view resolver -->
<bean
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/view/" />
<property name="suffix" value=".jsp" />
</bean>
</beans>
web.xml:
[![<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
id="WebApp_ID" version="3.1">
<display-name>spring-mvc-demo</display-name>
<!-- Spring MVC Configs -->
<!-- Step 1: Configure Spring MVC Dispatcher Servlet -->
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring-mvc-demo-servlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<!-- Step 2: Set up URL mapping for Spring MVC Dispatcher Servlet -->
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
I know there is a duplicate subjects in the site. I tried them also didn't reach the solution.
The problem might be the dash since it's not a valid a Java identifier Try renaming jsp and return fileName.
The page you're requesting from browser is not found, so you need to add URL in below pattern:
localhost:(Port number) /project name/(request mapping at controller) /(request mapping at method)
Try mapping URL and restart server.

"No WebApplicationContext found" error when adding css/js files to index.jsp

First, I want to apologize in advance if this question was already answered somewhere but I couldn't find a reasonable solution, and I would also say that's mainly because I'm pretty new to Java Spring Framework. I managed to deploy a simple application myself and I added some css/js files as well. However, specifically in the index.jsp file, I always receive:
"ERROR org.springframework.web.servlet.tags.UrlTag - No
WebApplicationContext found: not in a DispatcherServlet request and no
ContextLoaderListener registered? java.lang.IllegalStateException: No
WebApplicationContext found: not in a DispatcherServlet request and no
ContextLoaderListener registered?"
when adding these lines to the template:
<spring:url value="/resources/example1/css/main.css" var="mainCss" />
<link href="${mainCss}" rel="stylesheet" />
This is my web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name>CrunchifySpringMVCTutorial</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>example1</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>example1</servlet-name>
<url-pattern>/welcome.jsp</url-pattern>
<url-pattern>/welcome.html</url-pattern>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
</web-app>
This is my example1-servlet.xml
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package="com.example1.controller" />
<bean id="viewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />
</bean>
<mvc:resources mapping="/resources/**" location="/resources/example1"
cache-period="31556926"/>
<mvc:annotation-driven />
</beans>
This is my index.jsp
<%# taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<!DOCTYPE html>
<html>
<head>
<spring:url value="/resources/example1/css/main.css" var="mainCss" />
<link href="${mainCss}" rel="stylesheet" />
<%-- <spring:url value="/resources/example1/css/main.css" var="mainCss" /> --%>
<%-- <spring:url value="/resources/example1/js/main.js" var="mainJs" /> --%>
<%-- <spring:url value="/resources/example1/js/jquery-2.2.3.min.js" var="jqueryJs" /> --%>
<%-- <link href="${mainCss}" rel="stylesheet" /> --%>
<%-- <script src="${jqueryJs}"></script> --%>
<%-- <script src="${mainJs}"></script> --%>
</head>
<body>
</body>
</html>
Also, this is my file structure:
/WebContent
/META-INF
/resources
/example1
/css
-main.css
/js
-main.js
-jquery-2.2.3.min.js
/WEB-INF
/jsp
-welcome.jsp
-example1-servlet.xml
-web.xml
-index.jsp
with the other template (welcome.jsp), everything runs fine when adding the same resource files. Any ideias?
Thanks.
You need add listener org.springframework.web.context.ContextLoaderListener in web.xml :
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<display-name>CrunchifySpringMVCTutorial</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>example1</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>example1</servlet-name>
<url-pattern>/welcome.jsp</url-pattern>
<url-pattern>/welcome.html</url-pattern>
<url-pattern>*.html</url-pattern>
</servlet-mapping>
</web-app>

Primefaces Submit button of SelectOneButton does not work

As i am a newcomer for primefaces framework i tried to use SelectOneButton component with nearly the same code on primefaces.org's demo however i couldnt manage to get it work.
When i click on the submit button i cant see any result.
Below is my code for my xhtml and bean files. Any help is appreciated mostly. Thanks.
soru.xhtml file: (located under Webcontent/faces folder)
<h:form id="form">
<h:panelGrid columns="2" style="margin-bottom:10px" cellpadding="5">
<h:outputText value="Options: " />
<p:selectOneButton value="#{buttonBean.number}">
<f:selectItem itemLabel="Option 1" itemValue="1" />
<f:selectItem itemLabel="Option 2" itemValue="2" />
<f:selectItem itemLabel="Option 3" itemValue="3" />
</p:selectOneButton>
</h:panelGrid>
<p:commandButton value="Submit" update="display"/>
<h:outputText id="display" value="#{buttonBean.number}" />
</h:form>
ButtonBean.java file:
package com.ali.deneme;
import java.io.Serializable;
import javax.annotation.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.bean.ViewScoped;
import java.util.UUID;
#ManagedBean
#ViewScoped
public class ButtonBean implements Serializable {
/**
*
*/
private static final long serialVersionUID = 1L;
/**
* my ButtonBean class file - Ali Kerim Erkan
*/
private Integer number;
public Integer getNumber() {
return number;
}
public void setNumber(Integer number) {
this.number = number;
}
}
My web.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
id="WebApp_ID" version="3.0">
<display-name>deneme</display-name>
<welcome-file-list>
<!-- <welcome-file>/faces/hello.xhtml</welcome-file> -->
<!-- <welcome-file>/faces/datatableRowSelectionRadioCheckbox.xhtml</welcome-file> -->
<welcome-file>./faces/soru.xhtml</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>FacesServlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>FacesServlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<context-param>
<param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
<param-value>resources.application</param-value>
</context-param>
<servlet-mapping>
<servlet-name>FacesServlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>client</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.ALLOW_JAVASCRIPT</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.PRETTY_HTML</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.DETECT_JAVASCRIPT</param-name>
<param-value>false</param-value>
</context-param>
<context-param>
<param-name>org.apache.myfaces.AUTO_SCROLL</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<listener>
<listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
</web-app>
As #stg mentioned use
import javax.faces.bean.ManagedBean;
and also you are mapping two url-pattern to FacesServlet.
<servlet-mapping>
<servlet-name>FacesServlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>FacesServlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>FacesServlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
Remove mapping with '/faces/' pattern and use mapping with '.xhtml' pattern when calling your url.
example: http://example.com/page.xhtml
and please dont use faces as a directory name because it is not a good directory name for a JSF app.
faces is a common url pattern since first days of jsf.
You are using a wrong import. Instead of
import javax.annotation.ManagedBean;
you have to use
import javax.faces.bean.ManagedBean;

How stop richfaces style?

I develop this contact form:
<!DOCTYPE html>
<ui:composition
xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:a4j="http://richfaces.org/a4j"
xmlns:rich="http://richfaces.org/rich">
<h:form>
<h:panelGrid columns="3">
<h:outputLabel for="name" value="Nome (Obrigatório)" />
<h:inputText id="name" value="#{contact.client.name}" />
<h:message for="name" />
<h:outputLabel for="email" value="E-Mail (Obrigatório)" />
<h:inputText id="email" value="#{contact.client.email}" />
<h:message for="email" />
<h:outputLabel for="website" value="Website (Opcional)" />
<h:inputText id="website" value="#{contact.client.website}" />
<h:message for="website" />
</h:panelGrid>
<h:outputLabel for="text" value="Mensagem (Obrigatório):" /> <br/>
<h:inputTextarea id="text" value="#{contact.client.text}" rows="20" cols="80" /><br/>
<h:message for="text" />
<br/>
<h:commandButton value="Enviar" action="#{contact.sendMessage}" >
<f:ajax execute="#form" render="#form" />
</h:commandButton>
<h:outputText value="#{contact.messageStatus}" id="out" />
<a4j:status>
<f:facet name="start">
<h:graphicImage name="loader.gif" library="image" />
<h:outputText value="Enviando ..." />
</f:facet>
</a4j:status>
</h:form>
</ui:composition>
I import this composition in my contact page, but I don't know why, it puts this scripts in the end of the <h:head>..</h:head> section:
<script type="text/javascript" src="/Project/javax.faces.resource/jsf.js.xhtml?ln=javax.faces"></script>
<script type="text/javascript" src="/Project/javax.faces.resource/jquery.js.xhtml"></script>
<script type="text/javascript" src="/Project/javax.faces.resource/richfaces.js.xhtml"></script>
<script type="text/javascript" src="/Project/javax.faces.resource/richfaces-queue.js.xhtml"></script>
<script type="text/javascript" src="/Project/javax.faces.resource/richfaces-base-component.js.xhtml"></script>
<script type="text/javascript" src="/Project/javax.faces.resource/status.js.xhtml?ln=org.richfaces"></script>
I already try to disable richfaces style with this parameters in my web.xml:
<?xml version="1.0" encoding="UTF-8"?>
<web-app //.. configs>
<display-name>Project</display-name>
<context-param>
<param-name>javax.faces.INTERPRET_EMPTY_STRING_SUBMITTED_VALUES_AS_NULL</param-name>
<param-value>true</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.skin</param-name>
<param-value>plain</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.enableControlSkinning</param-name>
<param-value>false</param-value>
</context-param>
<welcome-file-list>
<welcome-file>index.xhtml</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
</web-app>
With these style, scripts that are added in the end of my section my footer just disappeared, how could I fix that ?
Any idea ?
I added these lines to the web.xml. This worked for me.
<context-param>
<param-name>org.richfaces.skin</param-name>
<param-value>plain</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.LoadStyleStrategy</param-name>
<param-value>None</param-value>
</context-param>
<context-param>
<param-name>org.richfaces.enableControlSkinning</param-name>
<param-value>false</param-value>
</context-param>

Resources