0

I use richfaces 4. I took an example from http://livedemo.exadel.com/richfaces-demo/richfaces/stateAPI.jsf?c=stateAPI. It works fine on livedemo site. But for me it doesn't work. I see in chrome (by developer tools) that there is no any request to the server when I click a4j:commandLink. I despair to find answer in the internet. What's wrong with code?

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

And managed 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() {

And I use 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 guava-14.0.1 cssparser-0.9.7

And I don't have any error message in my eclipse when I press a4j:commandlink. And my 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>
Foontik
  • 11
  • 5
  • You use RichFaces 4 but the demo site is for RichFaces 3.3. You should look at [RF4 showcase](http://showcase.richfaces.org/richfaces/component-sample.jsf). – Luiggi Mendoza Mar 22 '13 at 14:55
  • @Gamb please refer to [Multiple h:form in a JSF Page](http://stackoverflow.com/a/7372315/1065197). – Luiggi Mendoza Mar 22 '13 at 15:30

0 Answers0