8 Replies Latest reply on Mar 11, 2009 8:32 AM by jbalunas

    a4j:repeat not working

    jmiguel77

      Hi:

      I am using a4j in a project. I am trying to dinamically build a list of entries using a4j:repeater but i dont seem to be able to make it work

      This is my jsp:

      <a4j:form id="headForm" ajaxSubmit="true">
       <div id="infoBarContainer">
       <div id="infoBarContent">
       <h:outputLabel value="#{msg['common.company']}:" styleClass="normal" />
       <a4j:commandLink id="companyCommandLink" value="#{userDataManager.compania.nombre}" action="#{headManager.commandAction}" reRender="selectDataList" />
       <br />
       <h:outputLabel value="#{msg['common.agency']}:" styleClass="normal" />
       <a4j:commandLink id="agencyCommandLink" value="#{userDataManager.usuarioCentro.agencia.nombre}" action="#{headManager.commandAction}" reRender="selectDataList" />
       </div>
       <div style="float: left; width: 300px; overflow-y: auto; overflow-x: hidden;">
       <a4j:repeat id="selectDataList" binding="#{headManager.selectDataList}" value="#{headManager.valueList}" var="item" ajaxKeys="#{headManager.keys}">
       <h:outputText value="#{item.value}"/>
       </a4j:repeat>
       </div>
       </a4j:form>
      
      
      And this is the backing bean that supports the page (the relevant code):

      public class HeadBackingBean {
      
       private List<KeyValueBean> valueList;
      
       private UIRepeat selectDataList;
      
       private Set<Integer> keys = null;
      
       public String commandAction() {
       String username = getUserDataManager().getUsuario().getUsuario();
       List<CompaniaUsuarioCentroDTO> companyList = companyService.getCompaniaByUsername(username);
       if (companyList != null && companyList.size() > 0) {
       HashSet<Integer> ajaxKeys = new HashSet<Integer>();
       setValueList(new ArrayList<KeyValueBean>());
       int index = 0;
       for(CompaniaUsuarioCentroDTO item : companyList) {
       getValueList().add(new KeyValueBean(item.getCompania().getNoCia(), item.getCompania().getNombre()));
       System.out.println("data >>> " + item.getCompania().getNoCia() + " >>> " + item.getCompania().getNombre());
       ajaxKeys.add(index);
       System.out.println("index >>> " + index);
       index++;
       }
       setKeys(ajaxKeys);
       }
       return null;
       }
      

      The commandAction method is executing ok, no errors appear in the server log, or in the javascript of the page; but the a4j:repeat is not refreshed

      I think it should be working but ia am really new to Jboss a4j - richFaces so, i could really use some help


      Thanks a lot

        • 1. Re: a4j:repeat not working

          remove ajaxSubmit="true" first of all.

          • 2. Re: a4j:repeat not working
            jmiguel77

            Hi Sergey

            Ok, done. What's next ???

            thanks

            • 3. Re: a4j:repeat not working

              I does not work? Hmm, I am surprised.
              Add <a4j:log hotkey="M" /> on you page.
              Press Ctrl-Shift-M for popup.
              Click the ajax button (any of them)

              What does log say about "headForm:selectDataList"

              • 4. Re: a4j:repeat not working
                jmiguel77

                Hi Sergey

                I enclosed the a4j:repeat into an a4j:outputPanel, and it worked

                Also i changed the action of my commandLinks for an actionListener, but i am not sure that it represents any difference

                Thanks a lot for your time, i hope this topic to be helpfull for somebody else

                anyway i will try your recomendation and post the result

                • 5. Re: a4j:repeat not working

                  It was a bug in the RichFaces3.0.0/Ajax4jsf1.1.0 when pointing directly to the a4j:repeat (or rich:dataTable) does not work. Fixed already in SVN and available in snapshots

                  • 6. Re: a4j:repeat not working
                    jmiguel77

                    Hi:

                    i am facing a new problem; as i said, i enclosed the a4j:repeat inside a panel, so now is displaying ok, so i changed the h:outputText for a a4j:commandLink, so now my page is looking like this

                    <a4j:outputPanel id="selectPanel" layout="block" style="float:left;margin-top:5px;margin-left:5px;width:200px;">
                     <a4j:repeat id="selectDataList" binding="#{headManager.selectDataList}"
                     value="#{headManager.valueList}" var="item" ajaxKeys="#{headManager.keys}">
                     <a4j:commandLink id="selectCommandLink" value="#{item.value}" action="#{headManager.selectAction}"
                     actionListener="#{headManager.selectActionListener}" styleClass="headerSelectLink"
                     reRender="companyCommandLink,agencyCommandLink"/>
                     </a4j:repeat>
                     </a4j:outputPanel>
                    
                    
                    The problem is that, when i click on any of the new a4j:commandLink that are inside the a4j:repeat the called action or actionListener are never triggered, and thereby no update is processed in the client page

                    This is the output of the a4j:log:

                    debug[11:57:03,343]: Have Event [object Object] with properties: target: http://localhost:8080/administracion/faces/jsp/main/head.jsp#, srcElement: undefined, type: click
                    debug[11:57:03,343]: NEW AJAX REQUEST !!! with form :headForm
                    debug[11:57:03,343]: parameter headForm:selectDataList:0:selectCommandLink with value headForm:selectDataList:0:selectCommandLink
                    debug[11:57:03,343]: Start XmlHttpRequest
                    debug[11:57:03,343]: Reqest state : 1
                    debug[11:57:03,343]: QueryString: AJAXREQUEST=_viewRoot&headForm=headForm&autoScroll=&headForm%3A_idcl=
                    &headForm%3A_link_hidden_=
                    &jsf_tree_64=rO0ABXNyAEd<skipped>HBweHg%3D
                    &jsf_viewid=%2Fjsp%2Fmain%2Fhead.jsp&headForm%3AselectDataList%3A0%3AselectCommandLink
                    =headForm%3AselectDataList%3A0%3AselectCommandLink&
                    debug[11:57:03,343]: Reqest state : 1
                    debug[11:57:03,406]: Reqest state : 2
                    debug[11:57:03,406]: Reqest state : 3
                    debug[11:57:03,406]: Reqest state : 3
                    debug[11:57:03,406]: Reqest state : 3
                    debug[11:57:03,406]: Reqest state : 3
                    debug[11:57:03,406]: Reqest state : 4
                    debug[11:57:03,406]: Reqest end with state 4
                    debug[11:57:03,421]: Response with content-type: text/xml;charset=UTF-8
                    debug[11:57:03,421]: Full response content: <?xml version="1.0"?>
                     <html lang="es" xmlns="http://www.w3.org/1999/xhtml"><head><title></title>
                    <link type="text/css" rel="stylesheet" href="/administracion/common/css/global.css" />
                    <script type="text/javascript" src="/administracion/common/js/util.js"> </script>
                    <script type="text/javascript" src="/administracion/faces/a4j.res/org.ajax4jsf.framework.ajax.AjaxScript"> </script>
                    <script type="text/javascript" src="/administracion/faces/a4j.res/org/ajax4jsf/renderkit/html/scripts/form.js">
                     </script></head><body><meta name="Ajax-Update-Ids" content="" /><span id="ajax-update-ids">
                    <input type="hidden" name="jsf_tree_64"
                     id="jsf_tree_64" value="rO0AB<skipped>3Rw" /><input type="hidden" name="jsf_state_64" id="jsf_state_64" value="rO0AB<skipped>Hg="
                    /><input type="hidden" name="jsf_viewid" id="jsf_viewid"
                    value="/jsp/main/head.jsp" /></span><meta id="Ajax-Response"
                    name="Ajax-Response" content="true" /></body></html>
                    
                    debug[11:57:03,421]: Header Ajax-Update-Ids not found, search in <meta>
                    debug[11:57:03,421]: search for elements by name 'meta' in element #document
                    debug[11:57:03,421]: getElementsByTagName found 2
                    debug[11:57:03,421]: Find <meta name='Ajax-Update-Ids' content=''>
                    warn[11:57:03,421]: No information in response about elements to replace
                    debug[11:57:03,421]: call getElementById for id= ajax-update-ids
                    debug[11:57:03,421]: Hidden JSF state fields: [object HTMLSpanElement]
                    debug[11:57:03,421]: search for elements by name 'input' in element span
                    debug[11:57:03,421]: getElementsByTagName found 3
                    debug[11:57:03,421]: Replace value for inputs: 7 by new values: 3
                    debug[11:57:03,421]: Input in response: jsf_tree_64
                    debug[11:57:03,421]: Found same input on page with type: hidden
                    debug[11:57:03,421]: Input in response: jsf_state_64
                    debug[11:57:03,421]: Found same input on page with type: hidden
                    debug[11:57:03,437]: Input in response: jsf_viewid
                    debug[11:57:03,437]: Found same input on page with type: hidden
                    debug[11:57:03,437]: search for elements by name 'INPUT' in element span
                    debug[11:57:03,437]: getElementsByTagName found 0
                    debug[11:57:03,437]: Replace value for inputs: 7 by new values: 0
                    debug[11:57:03,437]: Call request oncomplete function after processing updates
                    debug[11:57:03,500]: call getElementById for id= _ajax:data


                    thanks again

                    • 7. Re: a4j:repeat not working
                      hhcofcmds

                      outputpanel solved my problem too.
                      a4j:commandLink is working well for me inside the reRendered a4j:repeat. I'm using 3.3.0GA.
                      cheers

                      • 8. Re: a4j:repeat not working
                        jbalunas

                        The Ajax4JSF Development and user forums are deprecated. Could you please post in the RIchFaces User forum. If needed for reference you can link or copy content from this topics.

                        Thanks,
                        Jay