Richfaces within Portlet working but NOT Ajax !
bjoernb Nov 14, 2007 5:58 AMHey guys !
I'm running into big trouble ! I'm trying to implement richfaces into portlets within the JBoss portal. I already solved the Servlet.service() error by editing the following src file decribed here https://jsfportletbridge.dev.java.net/nonav/issues/showattachment.cgi/8/crt-issue-20.txt.
After that all richfaces features are working except the AJAX features !!
I always get an "A4J not defined" from the IE and the Firefox!
So i tried the solution which the following thread describes:
http://jboss.com/index.html?module=bb&op=viewtopic&t=115538&start=10
But when I'm trying to do this I get the following error message:
javax.portlet.PortletException: Error processing execute lifecycle
So I'll post here the configuration of my working Richfaces-Portlet configuration which will get the "A4J not defined" error in hope someone can help me with that.
Thanks for any kind of input :)
i'm working with
jboss portal 2.6.2 GA bundled
richfaces 3.1.2 GA
jsf-portlet.jar (With Modified File FacesContextFactoryImpl.java and New File ServletContextHandler.java)
commons-digester-1.8.jar and commons-beanutils-1.7.0.jar
My configuration so far is as following:
index.jsp
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ page import="javax.portlet.*"%>
<%@ taglib uri="http://java.sun.com/portlet" prefix="portlet"%>
<portlet:defineObjects />
<f:view>
<rich:separator height="1" style="10px 0"/>
<h:panelGrid columns="2" width="100%" columnClasses="col">
<h:panelGroup>
This code does not work as expected. The expected echo text does not appear
below even the condition for <code>'renderer'</code> returns <code>true</code>.
Also, the error message does not appear when the length of the text reaches the limit.
</h:panelGroup>
<h:panelGroup>
This code works properly. The <code>h:message</code> is marked for update during
each Ajaxrequest/response. The place for bottom label is reserved with
<code>outputPanel</code> while the component is not rendered.
</h:panelGroup>
<a4j:outputPanel layout="block">
<h:message for="text1" style="color:red" />
<a4j:outputPanel layout="block">
<h:form>
<h:outputText value="Enter Text:"/>
<h:inputText id="text1" label="text1" value="#{rsBean.text1}">
<f:validateLength maximum="10"/>
<a4j:support event="onkeyup" reRender="out1" />
</h:inputText>
</h:form>
</a4j:outputPanel>
<h:outputText id="out1" rendered="#{not empty rsBean.text1}" value="Approved Text: #{rsBean.text2}" />
</a4j:outputPanel>
<a4j:outputPanel layout="block">
<a4j:outputPanel ajaxRendered="true">
<h:message for="text2" style="color:red" />
</a4j:outputPanel>
<a4j:outputPanel layout="block">
<h:form>
<h:outputText value="Enter Text:"/>
<h:inputText id="text2" label="text1" value="#{rsBean.text2}">
<f:validateLength maximum="10"/>
<a4j:support event="onkeyup" reRender="out2" />
</h:inputText>
</h:form>
</a4j:outputPanel>
<a4j:outputPanel layout="none">
<h:outputText id="out2" rendered="#{not empty rsBean.text2}" value="Approved Text: #{rsBean.text2}" />
</a4j:outputPanel>
</a4j:outputPanel>
</h:panelGrid>
<rich:separator height="1" style="10px 0"/>
</f:view>
rsBean.java
package de.sschmeckt.data;
public class rsBean
{
public String text1;
public String text2;
public String getText1(){
return text1;
}
public void setText1(String _text1){
text1=_text1;
}
public String getText2(){
return text2;
}
public void setText2(String _text2){
text2=_text2;
}
}
faces-config.xml
<?xml version='1.0' encoding='UTF-8'?> <faces-config version="1.2" 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-facesconfig_1_2.xsd"> <managed-bean> <managed-bean-name>rsBean</managed-bean-name> <managed-bean-class>de.sschmeckt.data.rsBean</managed-bean-class> <managed-bean-scope>request</managed-bean-scope> </managed-bean> </faces-config>
portlet.xml
<?xml version="1.0" encoding="UTF-8"?> <portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd" version="1.0"> <portlet> <description>HelloWorldPortlet</description> <portlet-name>HelloWorldPortlet</portlet-name> <display-name>HelloWorldPortlet</display-name> <portlet-class>com.sun.faces.portlet.FacesPortlet</portlet-class> <init-param> <description>Portlet init view page</description> <name>com.sun.faces.portlet.INIT_VIEW</name> <value>/WEB-INF/jsp/index.jsp</value> </init-param> <expiration-cache>0</expiration-cache> <supports> <mime-type>text/html</mime-type> <portlet-mode>VIEW</portlet-mode> </supports> <portlet-info> <title>HelloWorld Portlet</title> <short-title>HelloWorldPortlet</short-title> </portlet-info> </portlet> </portlet-app>
web.xml
<?xml version="1.0"?> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> <display-name>a4jEchoText</display-name> <context-param> <param-name>org.richfaces.SKIN</param-name> <param-value>blueSky</param-value> </context-param> <context-param> <param-name>javax.faces.STATE_SAVING_METHOD</param-name> <param-value>server</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> <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>*.jsf</url-pattern> </servlet-mapping> <login-config> <auth-method>BASIC</auth-method> </login-config> </web-app>