3 Replies Latest reply on Apr 25, 2011 5:41 AM by iabughosh

    Command Button Simple of RichFaces 4

    javacorner

      Hello,

      I'm testing an example from RichFaces 4.x Demo. It is Command Button Simple. I copied the code to my web project in separated page "example.xhtml" . I added all required libs. The problem is when I click the "say hello" button the whole page is refreshing when execute="@this" in the <a4j:commandButton> But in the demo site the action done without refreshing the page !!!

      following is the example code Plz help me to find what is wrong or what is missed:

       

       

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

      <ui:composition xmlns="http://www.w3.org/1999/xhtml"

          xmlns:h="http://java.sun.com/jsf/html"

          xmlns:f="http://java.sun.com/jsf/core"

          xmlns:ui="http://java.sun.com/jsf/facelets"

          xmlns:a4j="http://richfaces.org/a4j"

          xmlns:rich="http://richfaces.org/rich">

          <h:outputStylesheet>

              .outhello {

                  font-weight: bold;

              }

          </h:outputStylesheet>

          <h:form>

              <h:panelGrid columns="3">

                  <h:outputText value="Name:" />

                  <h:inputText value="#{userBean.name}" />

                  <a4j:commandButton value="Say Hello" render="out" execute="@form" />

              </h:panelGrid>

          </h:form>

          <br />

          <a4j:outputPanel id="out">

              <h:outputText value="Hello #{userBean.name} !"

                  rendered="#{not empty userBean.name}" styleClass="outhello" />

          </a4j:outputPanel>

      </ui:composition>

        • 1. Command Button Simple of RichFaces 4
          iabughosh

          hi mostafa,

          welcome to the forum, i think that you can't use execute="@this" with a4j:commandButton, i've tried your code with execute="{id for text}" only the output text has rendered :

           

          <!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:f="http://java.sun.com/jsf/core"

                xmlns:ui="http://java.sun.com/jsf/facelets"

                xmlns:a4j="http://richfaces.org/a4j"

                xmlns:rich="http://richfaces.org/rich">

           

           

           

           

                    <h:head>

           

                    </h:head>

                    <h:body>

                              <h:form>

                            <h:panelGrid columns="3">

                                <h:outputText value="Name:" />

                                <h:inputText id="t1" value="#{userBean.name}" />

                                <a4j:commandButton value="Say Hello" render="out" execute="t1" />

                            </h:panelGrid>

                        </h:form>

                        <br />

                        <a4j:outputPanel id="out">

                            <h:outputText value="Hello #{userBean.name} !"

                                rendered="#{not empty userBean.name}" />

                        </a4j:outputPanel>

                    </h:body>                 

          </html>

          • 2. Command Button Simple of RichFaces 4
            javacorner

            Many thanks man it is worked fine. But why it is working in the demo site with @this

            • 3. Command Button Simple of RichFaces 4
              iabughosh

              @this means execute the parent component, it is widely used with a4j:ajax, if you put @this in the previous example it means that execute the panelGrid which is not executable.

               

              note : i saw the demo and the execute on a4j:commandButton = "@form".

               

              regards.