4 Replies Latest reply on Nov 28, 2008 2:49 AM by Nicolas U.

    setStyleClass() method work only 1 time

    Nicolas U. Newbie

      Hello. i think i have found a bug:

      I can change the style 1 time but not more...


      JSF:

      <%-- jsf:pagecode language="java" location="/src/pagecode/Test.java" --%>
      <%-- /jsf:pagecode --%>
      <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
      <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
      <%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
      
      <html>
      <head>
      <title>Test</title>
      <script language="Javascript" type="text/javascript">
      </script>
      <style type="text/css">
      .inputError {
       border: 1px solid rgb(255, 0, 0) ! important;
       background-color: rgb(255, 239, 239) ! important;
      }
      
      .noError {
       border: 1px solid rgb(0, 0, 0) ! important;
       background-color: rgb(255, 255, 255) ! important;
      }
      </style>
      
      </head>
      <body>
      <f:view>
       <h:form>
       <h:inputText styleClass="noError" id="inputFileNumber" value="#{pc_Test.fileNumber}">
       <a4j:support event="onchange" action="#{pc_Test.doOnChangeFileNumber}" reRender="inputFileNumber" />
       </h:inputText>
       </h:form>
      </f:view>
      </body>
      </html>
      



      Backing Bean:
      import javax.naming.NamingException;
      
      import org.richfaces.component.html.HtmlInputText;
      
      public class Test extends PageCodeBase {
      
       protected HtmlInputText inputFileNumber;
       protected String fileNumber;
      
       public String getFileNumber() {
       return fileNumber;
       }
      
       public void setFileNumber(String fileNumber) {
       this.fileNumber = fileNumber;
       }
      
       protected HtmlInputText getInputFileNumber() {
       if (inputFileNumber == null) {
       inputFileNumber = (HtmlInputText) findComponentInRoot("inputFileNumber");
       }
       return inputFileNumber;
       }
      
       public void doOnChangeFileNumber() throws NamingException {
       if (fileNumber.equals("1")) {
       getInputFileNumber().setStyleClass("noError");
       } else {
       getInputFileNumber().setStyleClass("inputError");
       }
       }
      }