1 2 Previous Next 17 Replies Latest reply on Jul 25, 2007 5:10 PM by budoray

    Ajax4JSF Into Datatable does not work.

      hi all, i tried to use richfaces datatable, i have a4j:commandButton or a4j:commandLinks into one column but it does not work.

      is this known issue ?
      outside datatable a4j:commandButton or a4j:commandLinks works fine.


      Regards,
      Paata.

        • 1. Re: Ajax4JSF Into Datatable does not work.

          it is more important how you use, but not what you use. So, the posted code snippet will be fine to start.

          • 2. Re: Ajax4JSF Into Datatable does not work.

             

            "SergeySmirnov" wrote:
            it is more important how you use, but not what you use. So, the posted code snippet will be fine to start.

            hi sergey.
            1. xhtml :
            <rich:column>
             <a4j:commandButton reRender="PropertyList,scroll" action="#{propertyBean.editProperty}" value="Edit"/>
             &#160;/&#160;
             <a4j:commandButton reRender="PropertyList,scroll" action="#{propertyBean.removeProperty}" value="Remove"/>
             </rich:column>
            

            2.Bean :
            @Stateful
            @Name("propertyBean")
            public class PropertyManBean implements PropertyMan{
            
             @PersistenceContext
             EntityManager em;
            
             List<Property> properties;
            
             @In(create=true)
             @Out
             Property property;
            
            
             public List<Property> getProperties() {
             properties = (List<Property>)em.createNamedQuery("Property.findAll").getResultList();
             setSize(properties.size());
             return properties;
             }
            
             public void setProperties(List<Property> properties) {
             this.properties = properties;
             }
            
             public boolean getPropertyCount(){
             System.out.println("size = "+size);
             if (size<10) {
             return false;
             } else {
             return true;
             }
             }
            
             public void addProperty(){
             try {
             Users user = (Users)sessionContext.get("currentUser");
             property.setRecStatus(new Long(1));
             property.setRegDate(new java.sql.Date(System.currentTimeMillis()));
             property.setRemark("Property Parameter For User");
             property.setUserId(user);
             em.persist(property);
             } catch (Exception e) {
             e.printStackTrace();
             FacesMessages.instance().add("Could not Register. Please Trye Again");
             }
             }
            
             public void editProperty(){
             System.out.println("edit");
             }
             public void removeProperty(){
             System.out.println("remove");
             }
            
             @Remove
             @Destroy
             public void destroy() {}
            }
            
            


            • 3. Re: Ajax4JSF Into Datatable does not work.

              What are "PropertyList" and "scroll" ?

              • 4. Re: Ajax4JSF Into Datatable does not work.

                 

                "SergeySmirnov" wrote:
                What are "PropertyList" and "scroll" ?


                1.PropertyList is datatable :
                <rich:dataTable id="PropertyList"
                 var="prop"
                 rows="10"
                 onRowMouseOver="this.style.backgroundColor='#F1F1F1'"
                 onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
                 cellpadding="0"
                 cellspacing="0"
                 width="100%"
                 border="0"
                 value="#{propertyBean.properties}">
                 <f:facet name="header">
                 <rich:columnGroup>
                 <rich:column>
                 <h:outputText value="ID" />
                 </rich:column>
                 <rich:column>
                 <h:outputText value="Property Name" />
                 </rich:column>
                 <rich:column>
                 <h:outputText value="Status" />
                 </rich:column>
                 <rich:column>
                 <h:outputText value="User" />
                 </rich:column>
                 <rich:column>
                 <h:outputText value="Date" />
                 </rich:column>
                 <rich:column>
                 <h:outputText value="Action" />
                 </rich:column>
                 </rich:columnGroup>
                 </f:facet>
                 <rich:subTable
                 onRowMouseOver="this.style.backgroundColor='#F8F8F8'"
                 onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
                 var="inbox" value="#{prop}">
                 <rich:column>
                 <h:outputText value="#{prop.id}"></h:outputText>
                 </rich:column>
                 <rich:column>
                 <h:outputText value="#{prop.propertyName}"></h:outputText>
                 </rich:column>
                 <rich:column>
                 <h:outputText value="#{prop.statusStr}"></h:outputText>
                 </rich:column>
                 <rich:column>
                 <h:outputText value="#{prop.userId.userName}"></h:outputText>
                 </rich:column>
                 <rich:column>
                 <h:outputText value="#{prop.regTmpDate}"></h:outputText>
                 </rich:column>
                 <rich:column>
                 <h:outputText value="Edit">
                 <a4j:support ajaxSingle="true" event="onclick" action="#{propertyBean.editProperty}" reRender="PropertyList,scroll"></a4j:support>
                 </h:outputText>
                 &#160;/&#160;
                 <h:outputText value="Remove">
                 <a4j:support ajaxSingle="true" event="onclick" action="#{propertyBean.removeProperty}" reRender="PropertyList,scroll"></a4j:support>
                 </h:outputText>
                 </rich:column>
                 </rich:subTable>
                 </rich:dataTable>
                

                2. scroll is datascroller
                <rich:datascroller id ="scroll" align="right" rendered="#{propertyBean.propertyCount}" for="PropertyList" maxPages="2000" />
                


                • 5. Re: Ajax4JSF Into Datatable does not work.

                  i tried to use a4j:support but i got the same result.

                  • 6. Re: Ajax4JSF Into Datatable does not work.
                    ffffaces

                    I am working on the similar datatable as grdzeli_kaci,
                    I also observed that if I set up <a4j:commandlink> in facet that works but if I put <a4j:commandlink> in the row as grdzeli_kaci did, it did not work, BUT, if I clicked the link I put in facet first then clicked the link in the row it worked. It feels like there is a gate you need to open it first. I was going to ask question here. Hope Sergey can help us out

                    • 7. Re: Ajax4JSF Into Datatable does not work.

                      What exactly the version do you use?

                      • 8. Re: Ajax4JSF Into Datatable does not work.
                        ffffaces

                        I used richfaces-3.0.1 and ajax4jsf-1.1.1.

                        I followed your example for sorting table based on columns which are located in facet and they work fine. But if I put the commandlink in a row, any cell of the datatable, it did not work. If you click the link in the facet first as I said then click the link in the cell then it worked. My datatable is in a simpletogglepanel, if I set panel opened is false as default, as long as I open the panel every link in datatable works fine, if I set opened is true as default, the same thing will happen.

                        • 9. Re: Ajax4JSF Into Datatable does not work.

                          I used richfaces-3.0.2 and ajax4jsf-1.1.1.
                          I followed your example Sergey.
                          how i can resolve this problem ?

                          • 10. Re: Ajax4JSF Into Datatable does not work.

                            add a4j:log on the page. It should show the info how it update the DOM.

                            • 11. Re: Ajax4JSF Into Datatable does not work.
                              ffffaces

                              Hi Sergey,

                              I used a4j:log, I got a warning info

                              No information in response about elements to replace

                              I am new to richfaces and ajax4jsf, I have no idea where it could be possibly wrong? Could you please point out possible cases with this warning info?

                              Thanks

                              • 12. Re: Ajax4JSF Into Datatable does not work.
                                budoray

                                I had the same problem until I updated my jars. My jars were early snapshots of 3.0.1 and 1.1.1.

                                I am using <a4j:commandButton ...> inside a <rich:column> with no problems. However, using them in a subtable is a known issue.

                                • 13. Re: Ajax4JSF Into Datatable does not work.

                                  I used richfaces-3.0.2 and ajax4jsf-1.1.1.
                                  I followed your example Sergey.
                                  how i can resolve this problem ?

                                  • 14. Re: Ajax4JSF Into Datatable does not work.

                                    hi Sergey,
                                    i add a4j:log on the page and got this log :

                                    debug[21:06:12,166]: Have Event [object Object] with properties: target: http://localhost:8080/Billing/jguru/issue/content/admin/usrgrroles/propreg.seam?content=usersgr#, srcElement: undefined, type: click
                                    debug[21:06:12,167]: NEW AJAX REQUEST !!! with form :admbodyForm
                                    debug[21:06:12,168]: Append hidden control admbodyForm with value [admbodyForm] and value attribute [admbodyForm]
                                    debug[21:06:12,169]: Append text control admbodyForm:prpName with value [] and value attribute [null]
                                    debug[21:06:12,170]: Append hidden control javax.faces.ViewState with value [j_id5:j_id11] and value attribute [j_id5:j_id11]
                                    debug[21:06:12,171]: parameter admbodyForm:PropertyList:0:j_id224:0:j_id236 with value admbodyForm:PropertyList:0:j_id224:0:j_id236
                                    debug[21:06:12,172]: Start XmlHttpRequest
                                    debug[21:06:12,174]: Reqest state : 1
                                    debug[21:06:12,175]: QueryString: AJAXREQUEST=_viewRoot&admbodyForm=admbodyForm&admbodyForm%3AprpName=&javax.faces.ViewState=j_id5%3Aj_id11&admbodyForm%3APropertyList%3A0%3Aj_id224%3A0%3Aj_id236=admbodyForm%3APropertyList%3A0%3Aj_id224%3A0%3Aj_id236&
                                    debug[21:06:12,181]: Reqest state : 1
                                    debug[21:06:12,422]: Reqest state : 2
                                    debug[21:06:12,425]: Reqest state : 3
                                    debug[21:06:12,426]: Reqest state : 4
                                    debug[21:06:12,426]: Reqest end with state 4
                                    debug[21:06:12,427]: Response with content-type: text/xml;charset=UTF-8
                                    debug[21:06:12,428]: Full response content: <?xml version="1.0"?>
                                    <html xmlns="http://www.w3.org/1999/xhtml"><head><title></title><link type="text/css" rel="stylesheet" href="/Billing/a4j.res/css/toolBar.xcss/DATA/eAFbJaehBAADeAET" /><link type="text/css" rel="stylesheet" href="/Billing/a4j.res/css/panelbar.xcss/DATA/eAFbJaehBAADeAET" /><link type="text/css" rel="stylesheet" href="/Billing/a4j.res/css/panel.xcss/DATA/eAFbJaehBAADeAET" /><link type="text/css" rel="stylesheet" href="/Billing/a4j.res/css/table.xcss/DATA/eAFbJaehBAADeAET" /><link type="text/css" rel="stylesheet" href="/Billing/a4j.res/css/datascroller.xcss/DATA/eAFbJaehBAADeAET" /><script type="text/javascript" src="/Billing/a4j.res/org.ajax4jsf.framework.ajax.AjaxScript">
                                    </script><script type="text/javascript" src="/Billing/a4j.res/org.ajax4jsf.framework.resource.PrototypeScript">
                                    </script><script type="text/javascript" src="/Billing/a4j.res/org.ajax4jsf.framework.ajax.ImageCacheScript">
                                    </script><script type="text/javascript" src="/Billing/a4j.res/org/richfaces/renderkit/html/scripts/browser_info.js">
                                    </script><script type="text/javascript" src="/Billing/a4j.res/scripts/panelbar.js">
                                    </script></head><body><span id="admbodyForm:j_id205"></span><meta name="Ajax-Update-Ids" content="admbodyForm:j_id205" /><span id="ajax-update-ids"><input type="hidden" name="jsf_sequence" value="1" /><input type="hidden" name="javax.faces.ViewState" id="javax.faces.ViewState" value="j_id5:j_id14" /></span><meta id="Ajax-Response" name="Ajax-Response" content="true" /></body></html>
                                    debug[21:06:12,429]: Update page by list of rendered areas from response admbodyForm:j_id205
                                    debug[21:06:12,430]: search for elements by name 'script' in element #document
                                    debug[21:06:12,439]: getElementsByTagName found 5
                                    debug[21:06:12,440]: <script> in response with src=/Billing/a4j.res/org.ajax4jsf.framework.ajax.AjaxScript
                                    debug[21:06:12,441]: Such element exist in document
                                    debug[21:06:12,442]: <script> in response with src=/Billing/a4j.res/org.ajax4jsf.framework.resource.PrototypeScript
                                    debug[21:06:12,443]: Such element exist in document
                                    debug[21:06:12,444]: <script> in response with src=/Billing/a4j.res/org.ajax4jsf.framework.ajax.ImageCacheScript
                                    debug[21:06:12,445]: Such element exist in document
                                    debug[21:06:12,445]: <script> in response with src=/Billing/a4j.res/org/richfaces/renderkit/html/scripts/browser_info.js
                                    debug[21:06:12,446]: Such element exist in document
                                    debug[21:06:12,447]: <script> in response with src=/Billing/a4j.res/scripts/panelbar.js
                                    debug[21:06:12,448]: Such element exist in document
                                    debug[21:06:12,449]: search for elements by name 'link' in element #document
                                    debug[21:06:12,457]: getElementsByTagName found 5
                                    debug[21:06:12,458]: <link> in response with src=/Billing/a4j.res/css/toolBar.xcss/DATA/eAFbJaehBAADeAET
                                    debug[21:06:12,459]: Such element exist in document
                                    debug[21:06:12,460]: <link> in response with src=/Billing/a4j.res/css/panelbar.xcss/DATA/eAFbJaehBAADeAET
                                    debug[21:06:12,461]: Such element exist in document
                                    debug[21:06:12,462]: <link> in response with src=/Billing/a4j.res/css/panel.xcss/DATA/eAFbJaehBAADeAET
                                    debug[21:06:12,463]: Such element exist in document
                                    debug[21:06:12,464]: <link> in response with src=/Billing/a4j.res/css/table.xcss/DATA/eAFbJaehBAADeAET
                                    debug[21:06:12,465]: Such element exist in document
                                    debug[21:06:12,466]: <link> in response with src=/Billing/a4j.res/css/datascroller.xcss/DATA/eAFbJaehBAADeAET
                                    debug[21:06:12,467]: Such element exist in document
                                    debug[21:06:12,467]: Attempt to update part of page for Id: admbodyForm:j_id205
                                    debug[21:06:12,468]: call getElementById for id= admbodyForm:j_id205
                                    debug[21:06:12,469]: Replace content of node by replaceChild()
                                    debug[21:06:12,470]: search for elements by name 'script' in element span
                                    debug[21:06:12,478]: getElementsByTagName found 0
                                    debug[21:06:12,479]: Scripts in updated part count : 0
                                    debug[21:06:12,480]: Update part of page for Id: admbodyForm:j_id205 successful
                                    debug[21:06:12,481]: call getElementById for id= ajax-update-ids
                                    debug[21:06:12,481]: Hidden JSF state fields: [object HTMLSpanElement]
                                    debug[21:06:12,482]: Namespace for hidden view-state input fields is undefined
                                    debug[21:06:12,483]: search for elements by name 'input' in element span
                                    debug[21:06:12,489]: getElementsByTagName found 2
                                    debug[21:06:12,490]: Replace value for inputs: 7 by new values: 2
                                    debug[21:06:12,491]: Input in response: jsf_sequence
                                    debug[21:06:12,493]: Input in response: javax.faces.ViewState
                                    debug[21:06:12,494]: Found same input on page with type: hidden
                                    debug[21:06:12,495]: search for elements by name 'INPUT' in element span
                                    debug[21:06:12,501]: getElementsByTagName found 0
                                    debug[21:06:12,502]: Replace value for inputs: 7 by new values: 0
                                    debug[21:06:12,502]: call getElementById for id= _A4J.AJAX.focus
                                    debug[21:06:12,503]: No focus information in response
                                    


                                    is there anything incorrect ?

                                    1 2 Previous Next