2 Replies Latest reply on Aug 3, 2010 3:09 AM by flavioeasy

    try to enable ajax in a form

    flavioeasy

      Hi all,

      i'm trying to give ajax behavior to a simple form.

      Following the example on http://livedemo.exadel.com/richfaces-demo/richfaces/form.jsf i added 2 lines of code to an existing form, but i got 2 results :

      - the form behaves in the standard way (no ajax)

      - a little rectangle box is painted under my panel

      I run under tomcat 6, jdk1.6, richFaces 3.3.3.

      Can somebody help me ?

      Flavio

       

       

      Here the code :

       

      <html xmlns="http://www.w3.org/1999/xhtml"
            xmlns:h="http://java.sun.com/jsf/html"
            xmlns:ui="http://java.sun.com/jsf/facelets"
            xmlns:a4j="http://richfaces.org/a4j"
            xmlns:rich="http://richfaces.org/rich">
          <ui:composition>
              <rich:panel  style="width:300px">
                  <a4j:form ajaxSubmit="true" reRender="pass, mess">                          <-- added to enable ajax
                      <h:panelGrid columns="2" border="0" cellspacing="5">
                          <h:outputText value="#{mess.labelUser}" style="padding-right:5px"/>
                          <h:inputText id="usr" value="#{login.username}"   />

                          <h:outputText value="#{mess.labelPass}" style="padding-right:5px"/>
                          <h:inputSecret id="pass" value="#{login.password}"/>
                          <br/>
                          <h:commandButton value="login" action="#{login.doLogin}" styleClass="login-button"/>
                      </h:panelGrid>
                      <rich:messages  id="mess" style="color:red"/>
                  </a4j:form>                                                                                       <-- added to enable ajax
              </rich:panel>
          </ui:composition>>
      </html>

        • 1. Re: try to enable ajax in a form
          ilya_shaikovsky

          does that page included from some other or opened directly ? then add html-body structure and not use composition.

           

          if included - doublecheck that you have no nested forms.

           

          In that case it would be better to use just a4j:commandButton and not use ajaxSubmit=true. It was designed for the case when you have to use some existent components which works without ajax support and there are no alternatives.

          • 2. Re: try to enable ajax in a form
            flavioeasy

            Hi,

             

            it was included in a nested form that was useless, throwing that form it works great ;-)

             

            Thanks a lot

             

            Flavio