0 Replies Latest reply on Jul 2, 2011 4:43 AM by imcharsi

    hi. about <a4j:ajax/> and references component binding...

    imcharsi Newbie

      hi

       

      while i study richfaces, i found something suggestion for <a4j:ajax/>.

       

      first, let's see below code.

       

      =====

      <rich:dataTable binding="#{someBean.someBinding}" ...>
          ...
      </rich:dataTable>
      
      <a4j:commandLink ...>
          <a4j:ajax ... render="@this #{someBean.someBinding}"/>
      </a4j:commandLink>
      
      @ManagedBean
      @WhatEverScoped
      public class SomeBean implements ... {
          ...
          UIDataTable someBinding;
          public UIDataTable getSomeBinding() {return someBinding;}
          public void setSomeBinding(UIDataTable d) {someBinding=d;}
          ...
      }
      

      ======

       

      i thought how can i modify code for this usecase.

      in above expression, expression result is @this + #{someBean.someBinding}.toString(), for example "@this org.richfaces.component.UIDataTable@12354".

       

      so i have to split this inner expression from outter expression, and to evaluate each inner expression.

      if inner expression's value is instanceof UIComponent, put this component's client id into string buffer.

       

      if one more substitution was raised, use new result, otherwise(each expression's result is not instanceof UIComponent) use richfaces basic implementation.

       

      this test is for only <a4j:ajax/> tag's execute/render attribute usecase with directly component binding.

       

      this test is not for follow case.

       

      ====

      <a4j:ajax ... render="#{someBean.someTarget}"/>
      
      public Collection<UIComponent> getSomeTarget() {
          return ...;
      }
      

      ===

       

      nor

       

      ===

      <a4j:ajax ... render="#{someBean.someTarget}"/>
      
      public Collection<Object> getSomeTarget() {
          Collection col = new ArrayList<Object>();
          col.add("someId");
          col.add(someComponent);
          return col;
      }
      

      ===

      .

       

       

      related source is org.ajax4jsf.component.behavior.AjaxBehavior and

      i attached modified source.

      i tested this with mojarra 2.1.1-b04 and richfaces 4.0.1-snapshot and tomcat 7.0.14.

       

       

       

      how do you think about this?