3 Replies Latest reply on Feb 13, 2009 10:37 AM by Nick Belaevski

    CRITICAL BUG IN <rich:column>

    Dimitri Alexeev Newbie

      Having a pojo session bean with

      private boolean show;
      public boolean isShow() { return show; }
      public void setShow(boolean showed) { showed = show; }
      
      String bla;
      public void setBla(String v) { bla = v; }
      public String getBla() { return bla; }


      and

      selectOneMenu inside of <rich:column> inside of <f:facet name="header">:

      <html xmlns="http://www.w3.org/1999/xhtml"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:rich="http://richfaces.org/rich">
      <body>
      
      <h:form>
      
       <h:selectBooleanCheckbox value="#{sessionBean.show}"/>
       <h:commandButton value="submit" />
      
       <rich:dataTable>
       <f:facet name="header">
       <rich:column rendered="#{sessionBean.show}">
       <h:selectOneMenu value="#{sessionBean.bla}">
       <f:selectItem itemValue="" />
       <f:selectItem itemValue="someValue" />
       </h:selectOneMenu>
       </rich:column>
       </f:facet>
       </rich:dataTable>
      
      </h:form>
      </body>
      </html>


      We can reproduce one strange bug in 3 steps:
      1. Choose "someValue" from the < select > box
      2. Set checkbox to false and click submit
      -> setBla(v="someValue") was called
      -> column disappeared. < select > box disappeared
      3. Set checkbox to true and click submit
      -> setBla(v="null") was called. WHY?
      -> table appeared.
      -> the value of the < select > box is wrong

      By the way, replacing <rich:column> with <h:column> is a kind of workaround.

        • 1. Re: CRITICAL BUG IN <rich:column>
          Nick Belaevski Master

          Hi,

          There is an error in your code. rich:column should not be put inside "header" facet. After this change it works for me without problems. BTW, there's one more problem in the code: you should change how column is rendered by action, because in your case value of checkbox affects whether value of menu will be set to model and that doesn't seem a right behavior.

          • 2. Re: CRITICAL BUG IN <rich:column>
            Dimitri Alexeev Newbie

            Hi,

            "nbelaevski" wrote:
            Hi, There is an error in your code. rich:column should not be put inside "header" facet. After this change it works for me without problems.


            take a look at this code taken from
            http://livedemo.exadel.com/richfaces-demo-3.3.0.GA/richfaces/dataTable.jsf


            <f:facet name="header">
             <rich:columnGroup>
             <rich:column rowspan="2">


            In my example I removed columnGroup tag just to simplify the code. But the wrong behavior is still there - with or without < columnGroup >.


            BTW, there's one more problem in the code: you should change how column is rendered by action, because in your case value of checkbox affects whether value of menu will be set to model and that doesn't seem a right behavior.


            Again, I just tried to simplify the code. The problem is, the setter of property bla is called even if < select > control is not rendered. Take a look at this improved code:

            public class SessionBean {
            
             String bla="initial value";
            
             public void setBla(String v) {
             throw new UnsupportedOperationException("not-rendered component tries to call this setter! v=" + v);
             }
            
             public String getBla() {
             return bla;
             }
            
            }
            
            
            <html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core"
             xmlns:h="http://java.sun.com/jsf/html" xmlns:rich="http://richfaces.org/rich">
            <body><h:form>
            
            <h:commandButton value="submit" />
            
            <rich:dataTable>
             <f:facet name="header">
             <rich:column rendered="false">
             <h:selectOneMenu value="#{sessionBean.bla}"/>
             </rich:column>
             </f:facet>
            </rich:dataTable>
            
            </h:form></body>
            </html>
            


            click submit and check the stacktrace of the UnsupportedOperationException.

            There you can find the org.richfaces.component.UIColumn.processUpdates()
            which calls the method javax.faces.component.UIInput.processUpdates()
            but there are no rendered UIInput's on the page!


            • 3. Re: CRITICAL BUG IN <rich:column>
              Nick Belaevski Master

              Hello,

              Now I see what's wrong. Added a bug: https://jira.jboss.org/jira/browse/RF-6155. Thank you for posting!