5 Replies Latest reply on Dec 8, 2011 3:48 AM by blebleskeble

    rendering of outputPanel with dataTable

    blebleskeble Newbie

      HI all,

       

      im facing strange porblem in RF 4.1 CR1 (Apache Tomcat 6.0, el libs 2.2)

       

      I've got a4j:commandLink that launches action listener and render a4j:outputPanel. In this listener I change data that are displayed in a4j:outputPanel (There are some h:outputTexts and rich:dataTable)

      Problem is that data are succesfully changed in managed bean, all outputTexts are rendered with changes, but not dataTable. When I render this outputPanel again (with no changes in mb), table is succesfully rendered with proper values. (sources with exampple are attached)

       

      I hadn't this problem with RF 4.1 M3

       

      Is there some way for me to solve this problem?

        • 1. Re: rendering of outputPanel with dataTable
          Fekete Kamosh Newbie

          Hi,

           

          I think that there might be problem with components in RichFaces. But as a workaround try not to create new instance in randomizeContent() method. Instead clear items and refill them.

           

           

          private void randomizeContent() {
            Random r = new Random(System.currentTimeMillis());
            int num = (r.nextInt(20));
            name = "Size " + num;
          
            //items = new ArrayList<String>();
            items.clear();
            for (int i = 0; i < num; i++) {
              items.add("Item" + (i + 1));
            }
          }
          

           

          There would be problem that some component holds reference to list but you create the new one.

           

          Fekete

           

          PS: I think your example is not so big. Lets expose its code to attract more RichFaces guys

          1 of 1 people found this helpful
          • 2. Re: rendering of outputPanel with dataTable
            blebleskeble Newbie

            ok, so here are codes:

             

             

            DummyBean.java

            
            import java.io.Serializable;
            import java.util.ArrayList;
            import java.util.List;
            import java.util.Random;
            
            import javax.faces.bean.ManagedBean;
            import javax.faces.bean.ViewScoped;
            import javax.faces.event.ActionEvent;
            
            @SuppressWarnings("serial")
            @ManagedBean(name = "mb")
            @ViewScoped
            public class DummyBean implements Serializable{
                private String name;
                private List<String> items;
                
                public DummyBean() {
                    name = "";
                    items = new ArrayList<String>();
                    randomizeContent();
                }
            
                public String getName() {
                    return name;
                }
            
                public void setName(String name) {
                    this.name = name;
                }
            
                public List<String> getItems() {
                    return items;
                }
            
                public void setItems(List<String> items) {
                    this.items = items;
                }
                
                public void action(ActionEvent event) {
                    randomizeContent();
                }
                
                private void randomizeContent() {
                    Random r = new Random(System.currentTimeMillis());
                    int num = (r.nextInt(20));
                    name = "Size " + num;
                    
                    items = new ArrayList<String>();
                    for (int i = 0; i < num; i++) {
                        items.add("Item" + (i + 1));
                    }
                }
            }
            

             

            index.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:rich="http://richfaces.org/rich"
                  xmlns:a4j="http://richfaces.org/a4j">
            
                <h:head>
                    
                </h:head>
                
                <h:body>
                    <h:form id="myForm">
                        <a4j:commandLink id="link" value="Change" actionListener="#{mb.action}" render="panel" />
                        <br />
                        <a4j:commandLink id="refressh" value="Refresh" render="panel" />
                        <br />
                        <a4j:outputPanel id="panel" layout="block">
                            <h:outputText value="#{mb.name}" />
                            <rich:dataTable id="table" value="#{mb.items}" var="item">
                                <rich:column>
                                    <h:outputText value="#{item}" />
                                </rich:column>
                            </rich:dataTable>
                        </a4j:outputPanel>
                    </h:form>
                </h:body>
            </html>
            
            • 3. Re: rendering of outputPanel with dataTable
              blebleskeble Newbie

              Fekete Kamosh wrote:

               

              Hi,

               

              I think that there might be problem with components in RichFaces. But as a workaround try not to create new instance in randomizeContent() method. Instead clear items and refill them.

               

               

              private void randomizeContent() {
                Random r = new Random(System.currentTimeMillis());
                int num = (r.nextInt(20));
                name = "Size " + num;
               
                //items = new ArrayList<String>();
                items.clear();
                for (int i = 0; i < num; i++) {
                  items.add("Item" + (i + 1));
                }
              }
              

               

              There would be problem that some component holds reference to list but you create the new one.

               

              Fekete

               

              PS: I think your example is not so big. Lets expose its code to attract more RichFaces guys

              Yes, this solves my problem, thanks much.

              • 4. Re: rendering of outputPanel with dataTable
                blebleskeble Newbie

                Same problem occurs with collapsibleSubTable, but with my solution I'm not able to hold reference to its data object.

                • 5. Re: rendering of outputPanel with dataTable
                  blebleskeble Newbie

                  Solved in RF 4.1 CR2