7 Replies Latest reply on Apr 14, 2008 3:17 PM by arissonleal

    Problem With <a4j:commandButton>

    arissonleal

      When i use the a4j:commandButton to call a action that foward to other page using the navigation-rule, my rich:toolbar in the new page stop to work in Firefox.

      When a change for h:commandButton everything works fine in IE and Firefox.

      I'm using:

      Richfaces 3.1
      Facelets
      JSF 1.2

      What's the problem with the a4j:commandButton ?

        • 1. Re: Problem With <a4j:commandButton>
          ameo

          Hello,

          I have the same problem.

          -JBoss-Portal 2.6.4
          -RichFaces 3.2.0.GA
          -JBoss Portletbridge 1.0.0.B1
          -Facelets
          -SUN RI 1.2


          This example don't works with a4j:commandButton, but works fine with h:commandButton on both browsers.

          <a4j:commandButton action="MAIN" value="Back" />


          <navigation-rule>
           <from-view-id>*</from-view-id>
           <navigation-case>
           <from-outcome>MAIN</from-outcome>
           <to-view-id>mainworld.jsf</to-view-id>
           </navigation-case>
          </navigation-rule>
          


          • 2. Re: Problem With <a4j:commandButton>
            arissonleal

            I try the same approach with Richfaces 3.2 and the problem persist.

            Why the a4j:commandButton don't work ?

            • 3. Re: Problem With <a4j:commandButton>
              ilya_shaikovsky

              when you use navigation rules in a4j:command* components - you should place

              <redirect/>

              for the navigation case in faces-config defned.

              • 4. Re: Problem With <a4j:commandButton>
                moldovan

                Hy ilya!

                Is there a limitation in navigating with a4j:command* components when using redirect-Tag? Because it seems to me that i loose my faces-messages, when I'm doing it this way.

                Without redirect in nav-rule, i have problem with styles of richfaces-components, when I handle the site-navigation via a4j.

                • 5. Re: Problem With <a4j:commandButton>
                  maksimkaszynski

                  When you are using redirect, you make separate request to a new page. That results in loss of Faces Context with all its bells and whistles.

                  • 6. Re: Problem With <a4j:commandButton>
                    moldovan

                    thanks for the clarification maksim!

                    But what can I do, in my situation?
                    I have a site, which contains a4j:commandButton and action calls an execute-method. this methods executes an processaction and after this execution, it checks if process is finished or not:
                    -) if process is not finished, new content for inputs is loaded from db, an null will be returned to handle next task of process - so i will stay on the same site and site-content is rerendered.
                    -) if process is finished, I'm generating an facesMessage, and then sending a returnvalue (defined in one of my nav-rules) to jump to another site.

                    And here is the problem
                    -) if I do not use redirect-Tag in my nave-rule, i will loose the style of my richfaces-components on the other site (I don't know why).
                    -) if I use redirect-Tag in my nav-rule, i will loose the facesMessage, i generated in my action.

                    I can use normal h:commandButton without redirect-Tag in nav-rule for sure, but I want use ajax-navigation, because i stay several times on the same site, before jumping to the other.
                    But unfortunately I have no idea how I can achieve this with aj4:commandButton.

                    • 7. Re: Problem With <a4j:commandButton>
                      arissonleal

                      Here is my example to show my problem:

                      my template common.xhtml:

                      <?xml version="1.0" encoding="ISO-8859-1"?>
                      <!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:ui="http://java.sun.com/jsf/facelets"
                       xmlns:h="http://java.sun.com/jsf/html"
                       xmlns:f="http://java.sun.com/jsf/core"
                       xmlns:rich="http://richfaces.org/rich"
                       xmlns:a4j="http://richfaces.org/a4j">
                      
                       <f:loadBundle basename="resources.messages" var="msg" />
                       <head>
                       <title><ui:insert name="pageTitle">Page Title</ui:insert></title>
                       <style type="text/css">
                       body {
                       font-family: Verdana, Arial, Helvetica, sans-serif;
                       font-size: 14px;
                       }
                       .header {
                       font-family: Verdana, Arial, Helvetica, sans-serif;
                       font-size: 18px;
                       }
                       .bottom {
                       font-family: Verdana, Arial, Helvetica, sans-serif;
                       font-size: 9px;
                       text-align: center;
                       vertical-align: middle;
                       color: #8E969D;
                       }
                       </style>
                       </head>
                      
                      <body bgcolor="#ffffff">
                      
                      <table style="border:1px solid #CAD6E0" align="center" cellpadding="0" cellspacing="0" border="0" width="100%">
                      <tbody>
                      
                       <tr>
                       <td class="header" height="42" align="center" valign="middle" width="100%" bgcolor="#E4EBEB">
                       <ui:insert name="pageHeader">Page Header</ui:insert>
                       </td>
                       </tr>
                       <tr>
                       <td height="1" width="100%" bgcolor="#CAD6E0">
                       <h:form>
                      
                       <rich:toolBar id="toolbar">
                       <rich:dropDownMenu>
                       <f:facet name="label">
                       <h:panelGrid cellpadding="0" cellspacing="0" columns="2"
                       style="vertical-align:middle">
                       <h:outputText value="File" />
                       </h:panelGrid>
                       </f:facet>
                       <rich:menuItem submitMode="ajax" value="New" action="#{ddmenu.doNew}" />
                       <rich:menuItem submitMode="ajax" value="Open" action="#{ddmenu.doOpen}" />
                       <rich:menuItem submitMode="ajax" value="Close" action="#{ddmenu.doClose}" />
                       </rich:dropDownMenu>
                      
                       <rich:dropDownMenu>
                       <f:facet name="label">
                       <h:panelGrid cellpadding="0" cellspacing="0" columns="2"
                       style="vertical-align:middle">
                       <h:outputText value="Links" />
                       </h:panelGrid>
                       </f:facet>
                      
                       <rich:menuItem submitMode="none"
                       onclick="document.location.href='http://labs.jboss.com/jbossrichfaces/'">
                       <h:outputLink value="http://labs.jboss.com/jbossrichfaces/">
                       <h:outputText value="RichFaces Home Page"></h:outputText>
                       </h:outputLink>
                       </rich:menuItem>
                      
                       <rich:menuItem submitMode="none"
                       onclick="document.location.href='http://jboss.com/index.html?module=bb&op=viewforum&f=261'">
                       <h:outputLink
                       value="http://jboss.com/index.html?module=bb&op=viewforum&f=261">
                       <h:outputText value="RichFaces Forum"></h:outputText>
                       </h:outputLink>
                       </rich:menuItem>
                       </rich:dropDownMenu>
                       </rich:toolBar>
                       </h:form>
                      
                       </td>
                       </tr>
                      
                       <tr>
                       <td width="100%" colspan="2">
                       <table width="100%" style="height:150px" align="left" cellpadding="0" cellspacing="0" border="0">
                       <tbody>
                       <tr>
                       <td align="center" width="100%" valign="middle">
                      
                       <ui:insert name="body">Page Body</ui:insert>
                      
                       </td>
                       </tr>
                       </tbody>
                       </table>
                       </td>
                       </tr>
                      
                       <tr>
                       <td colspan="2" valign="bottom" height="1" width="100%" bgcolor="#CAD6E0"></td>
                       </tr>
                      </tbody>
                      </table>
                      
                      </body>
                      
                      </html>
                      



                      my inputname.xhtml:
                      <!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:ui="http://java.sun.com/jsf/facelets"
                       xmlns:h="http://java.sun.com/jsf/html"
                       xmlns:f="http://java.sun.com/jsf/core"
                       xmlns:c="http://java.sun.com/jstl/core"
                       xmlns:rich="http://richfaces.org/rich"
                       xmlns:a4j="http://richfaces.org/a4j">
                      
                       <f:loadBundle basename="resources.messages" var="msg" />
                      
                       <ui:composition template="common.xhtml">
                      
                       <ui:define name="pageTitle">JSF 1.2 and Facelets under Tomcat. KickStart Application</ui:define>
                      
                       <ui:define name="pageHeader">JSF 1.2 Hello Application</ui:define>
                      
                       <ui:define name="body">
                      
                      
                       <h:message showSummary="true" showDetail="false" style="color: red; font-weight: bold;" for="name" />
                      
                      
                       <a4j:form>
                       ${msg.prompt}
                       <h:inputText value="#{person.name}" required="true" id="name" label="Name" />
                       <a4j:commandButton action="greeting" value="Say Hello a4j" />
                       </a4j:form>
                      
                       </ui:define>
                       </ui:composition>
                      </html>
                      


                      my guess.xhtml
                      <!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:ui="http://java.sun.com/jsf/facelets"
                       xmlns:h="http://java.sun.com/jsf/html">
                      <body>
                      
                      <ui:composition template="/template.xhtml">
                      
                      This text will not be displayed.
                      
                       <ui:define name="title">
                       I'm thinking of a number from #{NumberBean.min} to #{NumberBean.max}. Can you guess it?
                       </ui:define>
                      
                      
                       <ui:define name="body">
                       <h:form id="helloForm">
                       <h:inputText type="text" id="userNo" value="#{NumberBean.guess}"
                       validator="#{NumberBean.validate}" />
                       <br />
                       <h:commandButton type="submit" id="submit" action="success"
                       value="Submit" />
                       <br />
                       <h:message showSummary="true" showDetail="false"
                       style="color: red; font-weight: bold;" id="errors1" for="userNo" />
                       </h:form>
                       </ui:define>
                      </ui:composition>
                      </body>
                      </html>
                      


                      faces-config.xml
                      <application>
                       <!-- tell JSF to use Facelets -->
                       <view-handler>com.sun.facelets.FaceletViewHandler</view-handler>
                       <message-bundle>resources.messages</message-bundle>
                       <locale-config>
                       <default-locale>pt_BR</default-locale>
                       <supported-locale>en</supported-locale>
                       </locale-config>
                       </application>
                       <managed-bean>
                       <managed-bean-name>person</managed-bean-name>
                       <managed-bean-class>demo.Person</managed-bean-class>
                       <managed-bean-scope>request</managed-bean-scope>
                       <managed-property>
                       <property-name>name</property-name>
                       <value />
                       </managed-property>
                       </managed-bean>
                      
                       <navigation-rule>
                       <from-view-id>/inputname.xhtml</from-view-id>
                       <navigation-case>
                       <from-outcome>greeting</from-outcome>
                       <to-view-id>/greeting.xhtml</to-view-id>
                       </navigation-case>
                       </navigation-rule>
                      


                      my messages.properties

                      prompt=Your Name\:
                      greeting=Hello

                      my Person.java
                      package demo;
                      
                      public class Person {
                       private String name;
                      
                       public Person() {
                       }
                      
                       public String getName() {
                       return name;
                       }
                      
                       public void setName(String name) {
                       this.name = name;
                       }
                      }
                      


                      When i summit the button in firefox my toolbar stop to work !!

                      What's wrong in my code ???

                      Thanks for help.