简体   繁体   中英

jsf with richfaces 3, ajax4jsf not working

I am using JSF with richfaces3.3.3, other jsf capabilities working but i don't know why ajax not working, for example

following is the ajax command button which does not give error not generate error

<a4j:commandButton value="Say Hello" render="out"/>

may be it is due to ajax4sf filter but i have the filter why it could not catch jsf request ?

Do i need myfaces to work with ajax4jsf ?

Following is my web.xml and rest of code.

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app 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">
     <description>Sample application</description>
     <display-name>richfaces-start</display-name>

      <context-param>
      <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
      <param-value>.xhtml</param-value>
     </context-param>

     <context-param>
      <param-name>facelets.REFRESH_PERIOD</param-name>
      <param-value>2</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>org.richfaces.SKIN</param-name>
      <param-value>blueSky</param-value>
     </context-param>

     <filter>
      <display-name>Ajax4jsf Filter</display-name>
      <filter-name>ajax4jsf</filter-name>
      <filter-class>org.ajax4jsf.Filter</filter-class>
     </filter>

     <filter-mapping>
      <filter-name>ajax4jsf</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>


     <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>
------------
start.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:h="http://java.sun.com/jsf/html"
      xmlns:a4j="http://richfaces.org/a4j"
      xmlns:rich="http://richfaces.org/rich"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets">

  <head><title>RichFaces</title></head>

  <body>

    <rich:panel header="RichFaces">
        <h:outputText value="Hello, looks like it's working" />
    </rich:panel>


    <h:form>
        <h:panelGrid columns="3">
            <h:outputText value="Name:" />
            <h:inputText value="#{userBean.name}" />
            <a4j:commandButton value="Say Hello" render="out"/>
        </h:panelGrid>
    </h:form>
    <br />

    <a4j:outputPanel id="out">
        <h:outputText value="Hello #{userBean.name} !"
            rendered="#{not empty userBean.name}" styleClass="outhello" />
    </a4j:outputPanel>
  </body>
</html>


In Richfaces 3.3.3, the a4j:commanButton doesn't have the attribute " render ". Instead, it has " reRender ". Change your attribute and it should work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM