7 Replies Latest reply on Mar 23, 2011 9:58 AM by Davide Malpassini

    Richfaces 4.0 datatable filtering

    Davide Malpassini Newbie

      I have a problem with filtering a rich:datable that not work properly if i set javax.faces.PARTIAL_STATE_SAVING = false,

      the problem can be reproduced with the demo of compotent setting the right cotext-param in web.xml.

      The proble is that i can't enable PARTIAL_STATE_SAVING because of a bug in the jsf 2.0 .

      Is there a work-around?

        • 1. Richfaces 4.0 datatable filtering
          Ilya Shaikovsky Master
          The proble is that i can't enable PARTIAL_STATE_SAVING because of a bug in the jsf 2.0 .

           

          whic one? maybe you could downgrade JSF 2 itself to some version where there is no such issue?

           

          P.S. https://issues.jboss.org/browse/RF-9333

          • 2. Richfaces 4.0 datatable filtering
            Davide Malpassini Newbie

            I have not tried but if i set the partial state to true if i try to render with ajax two combo from the second form in a second form  i obtain a satcktrace

            Caused by: java.lang.ClassCastException: javax.faces.component.StateHolderSaver cannot be cast to [Ljava.lang.Object;

            13:00:43,609 ERROR [STDERR]     at org.ajax4jsf.component.behavior.AjaxBehavior.restoreState(AjaxBehavior.java:342)

            if i disable the partail state is all ok i have tried the jsf2 version : 2.0.3, 2.0.4,2.1.0

            if you want me to try another version ask and i will try.

            • 3. Re: Richfaces 4.0 datatable filtering
              Davide Malpassini Newbie

              The Exception in the case of PARTIAL STATE =true i resolved hacking the class org.ajax4jsf.component.behavior.AjaxBehavior changing the method

               

               @Override
                  public void restoreState(FacesContext context, Object state) {
                      if (state != null) {
                          Object[] values =null;
                          if(state instanceof Object[]){
                              values= (Object[]) state;
                                      }else{
                              try {
                                  Field privateStringField = state.getClass().
                                  getDeclaredField("savedState");
              
                                  privateStringField.setAccessible(true);
              
                                  values = (Object[]) privateStringField.get(state);
                              } catch (SecurityException e) {
                                  // TODO Auto-generated catch block
                                  e.printStackTrace();
                              } catch (IllegalArgumentException e) {
                                  // TODO Auto-generated catch block
                                  e.printStackTrace();
                              } catch (NoSuchFieldException e) {
                                  // TODO Auto-generated catch block
                                  e.printStackTrace();
                              } catch (IllegalAccessException e) {
                                  // TODO Auto-generated catch block
                                  e.printStackTrace();
                              }
                          }
                          super.restoreState(context, values[0]);
              
                          if (values.length != 1) {
                              execute = restoreSet(PropertyKeys.execute, values[1]);
                              render = restoreSet(PropertyKeys.render, values[2]);
              
                              clearInitialState();
                          }
                      }
                  }
              

               

              I know that this is not a patch but i'm wondering why the method in this way have the correct behavior. I had to use the reflection because the class javax.faces.component.StateHolderSaver is private.

              Can someone help me to write a patch that resolve this issue?

              • 4. Richfaces 4.0 datatable filtering
                Nick Belaevski Master

                Hi,

                 

                Are you using MyFaces?

                • 5. Re: Richfaces 4.0 datatable filtering
                  Davide Malpassini Newbie

                  No i'm using Mojarra

                  • 6. Re: Richfaces 4.0 datatable filtering
                    Nick Belaevski Master

                    Can you please provide page/beans code to reproduce the problem?

                    • 7. Re: Richfaces 4.0 datatable filtering
                      Davide Malpassini Newbie

                      I will try , but for the proble, of filter in a datatable i simple get the showcase demo and punt in the web.xml

                      <context-param>

                        <param-name>javax.faces.PARTIAL_STATE_SAVING</param-name>

                        <param-value>false</param-value>

                      </context-param>

                      and test the datatable filtering, for the ClassCastException i will post the test case.