-
1. Struts 1 and Richfaces integration?
nbelaevski Feb 15, 2011 5:17 PM (in response to nick20_2005)Hi Nicolae,
In broader scope you are integrating with JSF and only then RichFaces; as the latter is an extension over JSF... try looking at http://shale.apache.org/ - there are some examples of such integration. Note that Shale project has been retired in 2009th, so integration can be tough, as JSF evolved much since that.
-
2. Re: Struts 1 and Richfaces integration?
nick20_2005 Feb 16, 2011 9:31 AM (in response to nbelaevski)Thanks for the answer. I have tried to integrate with JSF but unsuccessfully. When i try to call a Struts action it gives me following error:
javax.servlet.ServletException: org.apache.jasper.JasperException: An exception occurred processing JSP page /registration.jsp at line 12 9: </head> 10: 11: <body> 12: <f:view> 13: Test 14: </f:view> 15: </body> Stacktrace: org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:286) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913) org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449) javax.servlet.http.HttpServlet.service(HttpServlet.java:617) javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
My web.xml file looks like this:
<?xml version="1.0" encoding="UTF-8"?> <web-app id="WebApp_ID" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <display-name>StrutsFaces</display-name> <listener> <listener-class> org.apache.myfaces.webapp.StartupServletContextListener</listener-class> </listener> <!-- JavaServer Faces Servlet Configuration --> <servlet> <servlet-name>faces</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <!-- Action Servlet Configuration --> <servlet> <servlet-name>action</servlet-name> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class> <init-param> <param-name>config</param-name> <param-value>/WEB-INF/struts-config.xml</param-value> </init-param> <init-param> <param-name>debug</param-name> <param-value>3</param-value> </init-param> <init-param> <param-name>detail</param-name> <param-value>3</param-value> </init-param> <load-on-startup>2</load-on-startup> </servlet> <servlet> <servlet-name>Faces Config</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> </servlet> <!-- JavaServer Faces Servlet Mapping --> <servlet-mapping> <servlet-name>faces</servlet-name> <url-pattern>*.faces</url-pattern> </servlet-mapping> <!-- Action Servlet Mapping --> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <jsp-config> <taglib> <taglib-uri>/WEB-INF/tld/app</taglib-uri> <taglib-location>/WEB-INF/tld/app.tld</taglib-location> </taglib> <taglib> <taglib-uri>/WEB-INF/tld/struts-bean</taglib-uri> <taglib-location>/WEB-INF/tld/struts-bean.tld</taglib-location> </taglib> <taglib> <taglib-uri>/WEB-INF/tld/struts-logic</taglib-uri> <taglib-location>/WEB-INF/tld/struts-logic.tld</taglib-location> </taglib> <taglib> <taglib-uri>/WEB-INF/tld/struts-html</taglib-uri> <taglib-location>/WEB-INF/tld/struts-html.tld</taglib-location> </taglib> <taglib> <taglib-uri>/WEB-INF/tld/c</taglib-uri> <taglib-location>/WEB-INF/tld/c.tld</taglib-location> </taglib> <taglib> <taglib-uri>/WEB-INF/tld/fmt</taglib-uri> <taglib-location>/WEB-INF/tld/fmt.tld</taglib-location> </taglib> <taglib> <taglib-uri>/WEB-INF/tld/sql</taglib-uri> <taglib-location>/WEB-INF/tld/sql.tld</taglib-location> </taglib> <taglib> <taglib-uri>/WEB-INF/tld/struts-nested</taglib-uri> <taglib-location>/WEB-INF/tld/struts-nested.tld</taglib-location> </taglib> <taglib> <taglib-uri>/WEB-INF/tld/struts-tiles</taglib-uri> <taglib-location>/WEB-INF/tld/struts-tiles.tld</taglib-location> </taglib> <taglib> <taglib-uri>/WEB-INF/tld/x</taglib-uri> <taglib-location>/WEB-INF/tld/x.tld</taglib-location> </taglib> </jsp-config> <login-config> <auth-method>BASIC</auth-method> </login-config> </web-app>
The code from registration.jsp is:
<!doctype html public "-//w3c//dtd html 4.0 transitional//en"> <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%> <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%> <!-- RichFaces tag library declaration --> <html> <head> <title>RichFaces Greeter</title> </head> <body> <f:view> Test </f:view> </body> </html>
If i remove <f:view> tag and put simple html code it works fine. It seems that not recognize jsf libraries.
I have attach the project. All you need to do is to extract rar archive and import project into Eclipse.I don't know what i do wrong! Please help me!
I really need to integrate Struts with Jsf and then add Richfaces libraries.Thanks!
-
3. Re: Struts 1 and Richfaces integration?
nbelaevski Feb 16, 2011 3:43 AM (in response to nick20_2005)1 of 1 people found this helpfulJSF tags require FacesServlet to be in chain - looks like it's not so in your case.
-
4. Re: Struts 1 and Richfaces integration?
nick20_2005 Feb 16, 2011 9:16 AM (in response to nbelaevski)I have integrate jsf with my struts application and i have add the Richfaces libraries and everything works fine. Thanks a lot!
Now the web.xml looks like this:
<?xml version="1.0" encoding="UTF-8"?> <web-app id="WebApp_ID" version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <display-name>StrutsFaces</display-name> <context-param> <param-name>javax.faces.STATE_SAVING_METHOD</param-name> <param-value>server</param-value> </context-param> <context-param> <param-name>org.richfaces.SKIN</param-name> <param-value>wine</param-value> </context-param> <context-param> <param-name>org.richfaces.CONTROL_SKINNING</param-name> <param-value>enable</param-value> </context-param> <filter> <display-name>RichFaces Filter</display-name> <filter-name>richfaces</filter-name> <filter-class>org.ajax4jsf.Filter</filter-class> </filter> <filter-mapping> <filter-name>richfaces</filter-name> <servlet-name>Faces Servlet</servlet-name> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> <dispatcher>INCLUDE</dispatcher> </filter-mapping> <!-- <listener> <listener-class>com.sun.faces.config.ConfigureListener</listener-class> </listener> --> <!-- JavaServer Faces Servlet Configuration --> <servlet> <servlet-name>Faces Servlet</servlet-name> <servlet-class>javax.faces.webapp.FacesServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <!-- JavaServer Faces Servlet Mapping --> <servlet-mapping> <servlet-name>Faces Servlet</servlet-name> <url-pattern>*.jsf</url-pattern> </servlet-mapping> <!-- Action Servlet Configuration --> <servlet> <servlet-name>action</servlet-name> <servlet-class>org.apache.struts.action.ActionServlet</servlet-class> <init-param> <param-name>config</param-name> <param-value>/WEB-INF/struts-config.xml</param-value> </init-param> <init-param> <param-name>debug</param-name> <param-value>3</param-value> </init-param> <init-param> <param-name>detail</param-name> <param-value>3</param-value> </init-param> <load-on-startup>2</load-on-startup> </servlet> <!-- Action Servlet Mapping --> <servlet-mapping> <servlet-name>action</servlet-name> <url-pattern>*.do</url-pattern> </servlet-mapping> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> <jsp-config> <taglib> <taglib-uri>/WEB-INF/tld/app</taglib-uri> <taglib-location>/WEB-INF/tld/app.tld</taglib-location> </taglib> <taglib> <taglib-uri>/WEB-INF/tld/struts-bean</taglib-uri> <taglib-location>/WEB-INF/tld/struts-bean.tld</taglib-location> </taglib> <taglib> <taglib-uri>/WEB-INF/tld/struts-logic</taglib-uri> <taglib-location>/WEB-INF/tld/struts-logic.tld</taglib-location> </taglib> <taglib> <taglib-uri>/WEB-INF/tld/struts-html</taglib-uri> <taglib-location>/WEB-INF/tld/struts-html.tld</taglib-location> </taglib> <taglib> <taglib-uri>/WEB-INF/tld/c</taglib-uri> <taglib-location>/WEB-INF/tld/c.tld</taglib-location> </taglib> <taglib> <taglib-uri>/WEB-INF/tld/fmt</taglib-uri> <taglib-location>/WEB-INF/tld/fmt.tld</taglib-location> </taglib> <taglib> <taglib-uri>/WEB-INF/tld/sql</taglib-uri> <taglib-location>/WEB-INF/tld/sql.tld</taglib-location> </taglib> <taglib> <taglib-uri>/WEB-INF/tld/struts-nested</taglib-uri> <taglib-location>/WEB-INF/tld/struts-nested.tld</taglib-location> </taglib> <taglib> <taglib-uri>/WEB-INF/tld/struts-tiles</taglib-uri> <taglib-location>/WEB-INF/tld/struts-tiles.tld</taglib-location> </taglib> <taglib> <taglib-uri>/WEB-INF/tld/x</taglib-uri> <taglib-location>/WEB-INF/tld/x.tld</taglib-location> </taglib> </jsp-config> <login-config> <auth-method>BASIC</auth-method> </login-config> </web-app>
and in my struts-config.xml i have modified path from /registration.jsp in /registration.jsf:
<!-- Edit user registration --> <action path="/editRegistration" type="org.apache.struts.webapp.example2.EditRegistrationAction" attribute="registrationForm" scope="request" validate="false"> <forward name="register" path="/registration.jsf" /> </action>