2012-03-27 56 views
0

我使用JSF与richfaces3.3.3,其他JSF能力工作,但我不知道为什么AJAX不工作,例如JSF和RichFaces的3,Ajax4jsf的工作不

以下是AJAX命令按钮,不报错不产生错误

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

可能是由于ajax4sf过滤器,但我有过滤器为何无法赶上JSF请求?

我需要myfaces来使用ajax4jsf吗?

以下是我的web.xml和代码的其余部分。

<?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> 

回答

0


在RichFaces的3.3.3中,A4J:commanButton没有属性 “渲染”。相反,它有“reRender”。改变你的属性,它应该工作。