9 Replies Latest reply on Sep 18, 2008 5:23 AM by Metin OSMAN

    a4j:support issue on 3.2.2 ?

    Metin OSMAN Newbie

      Hi,

      I have just migrated from 3.2.1 to 3.2.2 and I am experiencing 2 problems with the a4j:support tag.


      1. As there is no "onclick" attribute on h:outputText, I used a4j:support to attach an action to the "onclick" event of the outputText (rendered as a span) :

      <h:outputText style="CURSOR: pointer" value="#{lbl.header_deconnexion}">
       <a4j:support event="onclick" onsubmit="window.location='session.stop'; return false;" />
      </h:outputText>
      


      As this does'nt work anymore, I had to change it to :

      <h:outputLabel style="CURSOR: pointer" value="#{lbl.header_deconnexion}" onclick="window.location='session.stop'; return false;" />
      


      2. Lets say I need to populate some data and then open a modalPanel on a given position.

      These lines used to work :

      <h:panelGrid columns="2">
       <h:column>
       <h:graphicImage alt="green"
       url="/resources/img/feurouge-vert-16x16.gif"
       styleClass="priorityIcon" rendered="false" />
       </h:column>
       <h:panelGrid cellpadding="0" cellspacing="0">
       <h:outputText value="Qualification" />
       <h:outputText value="#{client.qualification}%" />
       </h:panelGrid>
      
       <a4j:support action="#{client.openQualification}" immediate="true"
       reRender="..."
       event="onclick"
       oncomplete="showIndicatorModalPanel(this);" />
      </h:panelGrid>
      


      The showIndicatorModalPanel(this) js function calculate a position and open the modalPanel on this position.

      With 3.2.2, all the dom attributes relative to dimensions and positions of the clicked panelGrid are set to 0. Then, the calculated position is wrong and the modalPanel is misplaced.

      But when I call the same js function on the "onclick" attribute of the panelGrid, the modalPanel is correctly placed, but its data are not filled as I did not call the client.openQualification action.

      <h:panelGrid columns="2" onclick="showIndicatorModalPanel(this);">
       <h:column>
       <h:graphicImage alt="green"
       url="/resources/img/feurouge-vert-16x16.gif"
       styleClass="priorityIcon" rendered="false" />
       </h:column>
       <h:panelGrid cellpadding="0" cellspacing="0">
       <h:outputText value="Qualification" />
       <h:outputText value="#{client.qualification}%" />
       </h:panelGrid>
      </h:panelGrid>
      


      Any idea on what change could have make theses issues happen ?


        • 1. Re: a4j:support issue on 3.2.2 ?
          Ilya Shaikovsky Master

          1) why do you think that this is RF problem? If onclick="alert('!')" will works on the component - then support will also works. But if the components itself doesn't encodes this attribute - we could do nothing here.

          2) could you please share more full example with us. It's difficult to check using explanation only.

          • 2. Re: a4j:support issue on 3.2.2 ?
            Metin OSMAN Newbie

            1. As the h:ouputText can render itself as simple text or span depending on whatever it has style or styleClass set, there is no onclick attribute on the element. But, the fact is that whenever it is rendered as a span, it should accept onclick attribute. Therefore, I used a4j:support in order to attach a js function on the onclick. As I suppose this is done on render phase, the outputText is rendered as a span and the the a4j:support correctly attaches the function to the onclick event.

            The code sample I provided used to work before 3.2.2. Maybe, this should not have worked, and I was exploiting a flaw. I just want to be sure if this is a regression or if it never should have worked.

            2. try this simple code
            Facelets 1.1.14, Richfaces 3.2.2, JSF RI 1.2_09 or 1.2_04-P02
            JBoss 4.2.2

            <!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:a4j="http://richfaces.org/a4j"
             xmlns:rich="http://richfaces.org/rich"
             xmlns:c="http://java.sun.com/jstl/core" xml:lang="en" lang="en">
             <head>
             <meta http-equiv="Content-Type"
             content="text/html; charset=iso-8859-1" />
             </head>
            
             <body>
             <h:form>
             <h:panelGrid>
             <h:outputText value="Sample" />
             <a4j:support action="#{skinBean.getSkin}" event="onclick"
             oncomplete="alert(this.tagName + ' : ' + this.clientHeight);" />
             </h:panelGrid>
            
             <h:panelGrid onclick="alert(this.tagName + ' : ' + this.clientHeight);">
             <h:outputText value="Sample" />
             </h:panelGrid>
             </h:form>
             </body>
            </html>
            


            With 3.2.1 it used to work.

            I think these 2 issues are linked, and maybe these are not issues and my samples were exploiting a code flaw.


            • 3. Re: a4j:support issue on 3.2.2 ?
              Nick Belaevski Master

              Metin,

              Can you please provide full page code for the second issue you're describing?

              • 4. Re: a4j:support issue on 3.2.2 ?
                Nick Belaevski Master

                Metin,

                I cannot reproduce the issue using page code you've posted. What browser do you use?

                • 5. Re: a4j:support issue on 3.2.2 ?
                  Pascal Paoli Newbie

                  Hi,

                  I have a similar problem with a4j:support with richFaces 3.2.2

                  This is my code :

                  <a4j:region renderRegionOnly="true">
                   <ui:decorate template="#{percorso}/templates/form_fields.xhtml">
                  
                   <ui:define name="field_label">
                   <h:outputText style="font-weight: bold; font-size: 8.5pt;"
                   value="#{msg['step1.nome']}" />
                   </ui:define>
                   <ui:define name="field">
                   <h:panelGroup id="field_name">
                   <h:inputText id="step1_nome" validator="NameValidator"
                   required="true"
                   styleClass="#{ManagedBeanNavigationSignup.view.style['ERROR_01']}"
                   value="#{customer.firstName}">
                   <a4j:support event="onblur" reRender="field_name, msg_nome"
                   eventsQueue="foo" limitToList="true"
                   ignoreDupResponses="true">
                   </a4j:support>
                   </h:inputText>
                   </h:panelGroup>
                   </ui:define>
                   <ui:define name="message">
                   <rich:message id="msg_nome" for="step1_nome" infoClass="info"
                   styleClass="error-message">
                   <f:facet name="errorMarker">
                   <h:graphicImage value="#{percorso}/images/error.gif" />
                   </f:facet>
                   <f:facet name="passedMarker">
                   <h:panelGroup
                   rendered="#{ManagedBeanNavigationSignup.view.errors['ERROR_01']}">
                   <h:graphicImage value="#{percorso}/images/error.gif" />
                   <h:outputText value="#{error['ERROR_01']}"
                   styleClass="error-message" />
                   </h:panelGroup>
                   </f:facet>
                   </rich:message>
                   </ui:define>
                   </ui:decorate>
                  </a4j:region>


                  With richesFaces 3.2.1 it works well, but with richFaces 3.2.2 it doesn't work ("AJ4 unhandled"). It begin to work well only after a submit action.

                  I try to use IE6 , IE7, FireFox3 and Google Chrome but I have the same problem.

                  It seams that only before the first submit action the richFaces 3.2.2. doesn't bind the a4j:region

                  Thanks in advance.

                  • 6. Re: a4j:support issue on 3.2.2 ?
                    Nick Belaevski Master

                    Can you post #{percorso}/templates/form_fields.xhtml also?

                    • 7. Re: a4j:support issue on 3.2.2 ?
                      Pascal Paoli Newbie

                      This is the code :

                      form_fields.xhtml

                      
                      <ui:composition
                       xmlns="http://www.w3.org/1999/xhtml"
                       xmlns:ui="http://java.sun.com/jsf/facelets"
                       >
                       <tr style="font-size:10px; color:#000000; background-color: #F3F5F7;" valign="middle">
                       <td width="5px" height="5px">
                       <b><ui:insert name="field_optional"/></b>
                       </td>
                       <td width="200px">
                       <b><ui:insert name="field_label"/></b>
                       </td>
                       <td width="300px">
                       <ui:insert name="field"/>
                       </td>
                       <td width="245px">
                       <ui:insert name="message"/>
                       </td>
                       </tr>
                      </ui:composition>
                      


                      It is really strange that it starts to work only after the first submit action. The code is the same. I have this problem only in the first page.

                      • 8. Re: a4j:support issue on 3.2.2 ?
                        Ilya Shaikovsky Master

                        Vendetta, sorry but I could not reproduce "a4j not defined" error. could you please send me your sample in war?

                        • 9. Re: a4j:support issue on 3.2.2 ?
                          Metin OSMAN Newbie

                          Nick, Ilya,

                          mea culpa the first issue was certainly due to my Eclipse or a cache problem in my JBossAS. Cleaning both of them has solved the issue.

                          for the second one, try the following sample, you will notice that 'this' isn't the same before and after action call.

                          <!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:a4j="http://richfaces.org/a4j"
                           xmlns:rich="http://richfaces.org/rich"
                           xmlns:c="http://java.sun.com/jstl/core" xml:lang="en" lang="en">
                           <head>
                           <meta http-equiv="Content-Type"
                           content="text/html; charset=iso-8859-1" />
                           </head>
                          
                           <body>
                           <h:form>
                           <h:panelGrid>
                           <h:outputText value="Sample" />
                           <a4j:support action="#{skinBean.getSkin}" event="onclick"
                           onsubmit="alert(this.tagName + ' : ' + this.clientHeight);"
                           oncomplete="alert(this.tagName + ' : ' + this.clientHeight);" />
                           </h:panelGrid>
                           </h:form>
                           </body>
                          </html>
                          


                          This does not explain why in my app the clicked object has all of its dimensions and positions set to 0.
                          I am currently trying to isolate a sample.

                          Regards,