5 Replies Latest reply on May 10, 2010 4:14 AM by omergillani

    Richfaces a4j:commandButton problem

    omergillani

      I am newbie in richfaces. i need to use richfaces in my project. i am  facing problem in a4j:commandButton it is not calling my bean action  method

       

      login.jsp

      {code}

      <!doctype html  public "-//w3c//dtd html 4.0 transitional//en">
      <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
      <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
      <!-- RichFaces tag library declaration -->
      <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
      <%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>

       

      <f:view>
           <a4j:form>
               <rich:panel style="width: 400px">
                   <f:facet name="header">
                       <h:outputText value="Login" />
                   </f:facet>
                   <h:panelGrid width="100%" columns="2" style="width:  400px">
                       <h:outputText value="Username: " styleClass="label"  />
                       <h:inputText value="#{UserBean.username}"  rendered="true">
                           <%-- <f:validateLength minimum="1"  maximum="50" />  --%>
                       </h:inputText>
                       <h:outputText value="Password: " styleClass="label"  />
                       <h:inputSecret value="#{UserBean.password}"  rendered="true" >
                           <%-- <f:validateLength minimum="1"  maximum="50" /> --%>
                       </h:inputSecret>

       

                      <h:outputText value="" styleClass="label"  />
                       <h:commandButton value="Login"  action="#{UserBean.authorize}" />
                   </h:panelGrid>
               </rich:panel>
           </a4j:form>
      </f:view>

      {code}

       

      UserBean.java

      {code}

      public class UserBean implements ActionListener, Serializable {

       

          /** Creates a new instance of UserBean */
          private UIInput username;
          private UIInput password;

       

          public UIInput getPassword() {
              return password;
          }

       

          public void setPassword(UIInput password) {
              this.password = password;
          }

       

          public UIInput getUsername() {
              return username;
          }

       

          public void setUsername(UIInput username) {
              this.username = username;
          }

       

          public UserBean() {
          }

       

          public String authorize() {
              String status = "failure";
              try {
                  System.out.println("Testing Autorize Method");
              } catch(Exception e) {
                  e.printStackTrace();
              }
              return status;
          }

       

          public void processAction(ActionEvent event) throws AbortProcessingException {
              System.out.println("Process Action.......");
          }

       

          public void validate() {
              System.out.println("VAlidate.......");
          }
      }

      {code}