2 Replies Latest reply on Apr 28, 2008 8:59 AM by Volker Schmidt

    disabled commandButton does not work after enabling (richfac

    Volker Schmidt Newbie

      Hi guys.

      My problem is simple: I try to enable a disabled commandButton after rerendering the surrounding outputPanel. The commandButton gets enabled but does not work correctly. Once pressed, the constructor of the managed bean gets called but not the related method. This problem occurs only if the button is in disabled state when the page is loaded. There is no error log or any hint that something fails. I also tried it with richFaces 3.2.1 SP2 and 3.1.5 CR2 - same effect. Also using JSF RI instead of MyFaces has no effect.

      Here is the jsp code I use. (The previous commandButton is disabled when page is loaded. Clicking on next button enables the previous commandButton.)

      <?xml version="1.0" encoding="UTF-8" ?>
      <%@ 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 language="java" contentType="text/html; charset=UTF-8"
      <!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"
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
      <title>Insert title here</title>
      <link rel="Stylesheet" href="resources/css/styles.css"/>
       <a4j:outputPanel id="panel">
       <h:inputHidden value="#{dataTableBean.tablePages}"/>
       <h:inputHidden value="#{dataTableBean.tablePage}"/>
       <h:panelGrid columns="5">
       <a4j:commandButton value="Previous" actionListener="#{dataTableBean.previous}" disabled="#{dataTableBean.tablePage == 1}" reRender="panel"/>
       <h:outputText value="#{dataTableBean.tablePage}"/>
       <h:outputText value="/"/>
       <h:outputText value="#{dataTableBean.tablePages}"/>
       <a4j:commandButton value="Next" actionListener="#{dataTableBean.next}" disabled="#{dataTableBean.tablePage == dataTableBean.tablePages}" reRender="panel"/>

      This is the request scope managed bean (without getter and setter):
       private int tablePages = 10;
       private int tablePage = 1;
       public DataTableBean() {
       public void next(ActionEvent event) {
       System.out.println("Next page");
       public void previous(ActionEvent event) {
       System.out.println("Previous page");