a4j:commandLink不执行请求

时间:2013-03-22 14:19:55

标签: jsf richfaces ajax4jsf commandlink

我使用richfaces 4.我从http://livedemo.exadel.com/richfaces-demo/richfaces/stateAPI.jsf?c=stateAPI举了一个例子。它在livedemo网站上运行良好。但对我来说它不起作用。我在chrome(通过开发人员工具)中看到,当我单击a4j:commandLink时,没有任何对服务器的请求。我绝望在互联网上找到答案。代码有什么问题?

<!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"> 

<h:head></h:head> 
<h:body>

    <center>
    <rich:panel style="width:320px;" id="panel">
        <f:facet name="header">
            <h:panelGroup>
                <h:outputText value="Login"/>
                <a4j:commandLink action="#{userBean.doSwitch}" value="(to register)" immediate="true" 
                    render="panel"  />
            </h:panelGroup>
        </f:facet>

        <rich:message for="action"/>

        <h:panelGrid columns="3"  columnClasses="col1,col2">
            <h:outputText value="username"/>
            <h:inputText value="#{userBean.login}" id="login" required="true">
                <f:validateLength minimum="3" maximum="30"/>
            </h:inputText>
            <rich:message for="login" showSummary="false"/>
                <h:outputText value="password"/>
                <h:inputSecret value="#{userBean.password}" id="password" required="true">
                    <f:validateLength minimum="5" maximum="30"/>
                </h:inputSecret>
                <rich:message for="password"/>
            <h:outputText value="confirm" rendered="#{userBean.state}"/>
            <h:inputSecret value="#{userBean.passwordConfirmation}" 
                    rendered="#{userBean.state}" id="passwordConfirmation" required="true">
                <f:validateLength minimum="5" maximum="30"/>
            </h:inputSecret>
            <rich:message for="passwordConfirmation"/>
        </h:panelGrid>

        <a4j:commandButton action="#{userBean.doLogin}" rendered="#{!userBean.state}" value="login" id="actionL"/>
        <a4j:commandButton action="#{userBean.doRegister}" rendered="#{userBean.state}" value="register" id="actionR"/>

    </rich:panel>
    </center>

</h:body>
</html>

托管bean

@ManagedBean
@SessionScoped
public class UserBean {

    private String login;
    private String password;
    private String passwordConfirmation; 
    private boolean state; 

    public UserBean() {
        super();
        this.state = false;
    } 

    public boolean isState() {
        return state;
    }

    public void setState(boolean state) {
        this.state = state;
    } 

    public String doSwitch(){
        this.setState(true);
        return "loginss";
    }

    public String doLogin() {
        return "done";
    }

    public String doRegister() {

我使用libs:

  

richfaces-core-impl-4.3.1.Final   richfaces-core-api-4.3.1.Final   richfaces-components-ui-4.3.1.Final   richfaces-components-api-4.3.1.Final   sac-1.3 javax.faces-2.1.7   番石榴14.0.1   cssparser-0.9.7

当我按a4j:commandlink时,我的日食中没有任何错误消息。 还有我的web.xml

<welcome-file-list>
    <welcome-file>/faces/register.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.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>facelets.DEVELOPMENT</param-name>

  <param-value>true</param-value>

 </context-param>

 <context-param>

  <param-name>facelets.SKIP_COMMENTS</param-name>

  <param-value>true</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>glassX</param-value>

 </context-param>

 <filter>

  <display-name>Ajax4jsf Filter</display-name>

  <filter-name>ajax4jsf</filter-name>

  <filter-class>org.ajax4jsf.Filter</filter-class>

 </filter>

0 个答案:

没有答案