1 Reply Latest reply on Apr 4, 2013 10:07 PM by tehackio teha

    ExtendedDataModel ajax call fail

    tehackio teha Newbie

      If one ajax call inside column of org.ajax4jsf.model.ExtendedDataModel to render outside, method walk is called many times;

       

       

              <h:form id="frmmm">
                <rich:dataTable
                          id="dtSearch"
                          value="#{productView.productQuery}" 
                          var="reg"
                          rows="20"
                          style="width: 100%"
                          >
                          <rich:column>
                                    <h:graphicImage library="padrao" name="img/find00.png">
                                              <f:ajax
                                                        event="click"
                                                        execute="@this"
                                                        render=":frmmm:tesssst"
                                                        action="#{productView.becomeManaged(reg)}"
                                                        />
                                    </h:graphicImage>
                                    <a4j:commandLink
                                              execute="@this"
                                              limitRender="true"
                                              action="#{productView.becomeManaged(reg)}"
                                              render="tesssst"
                                    >
                                              <h:graphicImage library="patterrr" name="img/find01.png" />
                                    </a4j:commandLink>
                          </rich:column>
                </rich:dataTable>
                <h:panelGroup id="tesssst">#{currentDate}</h:panelGroup>
                </h:form>
      

       

       

      @Override
                public void walk(FacesContext context, DataVisitor visitor, Range range, Object argument) {
                          List<T> resultado = null;
                          SequenceRange sequenceRange = (SequenceRange) range;
                          try {
                                    CriteriaQuery<T> query = getQuery();
      //                              CriteriaQuery<T> tmpCriteria = query;
      //                              CriteriaQuery<Long> countCriteria = JpaUtils.countCriteria(getEm(), tmpCriteria);
      //                              setRowCount(((Long) getEm().createQuery(countCriteria).getSingleResult()).intValue());
                                    resultado = getEm().createQuery(query).setFirstResult(sequenceRange.getFirstRow()).setMaxResults(sequenceRange.getRows()).getResultList();
                                    for (T t : resultado) {
                                              visitor.process(context, t.getId(), argument);
                                    }
      //                              List<Order> orderList = query.getOrderList();
                          } catch (Exception e) {
                                    e.printStackTrace();
                          }
                }
        
                @Override
                public T getRowData() {
                          return getEm().find(getClasse(), getRowKey());
                }
      
      
                @Override
                public boolean isRowAvailable() {
                          return getRowKey() != null;
                }
      
      
                @Override
                public int getRowIndex() {
                          return 0;
                }
      
      
                @Override
                public void setRowIndex(int rowIndex) {
        
                }
      
      
                @Override
                public Object getWrappedData() {
                          return new UnsupportedOperationException();
                }
      
      
                @Override
                public void setWrappedData(Object data) {
                          throw new UnsupportedOperationException();
                }
      
      
                @Override
                public void arrange(FacesContext context, ArrangeableState state) {
                          setArrangeableState(state);
                }
      
      
                @Override
                public int getRowCount() {
                          CriteriaQuery<Long> countCriteria = JpaUtils.countCriteria(getEm(), getQuery());
                          return ((Long) getEm().createQuery(countCriteria).getSingleResult()).intValue();
                }
      
      

       

       

       

      UIDataTable(UIDataAdaptor).walk(FacesContext, DataVisitor, Object) line: 809
      
      
      UIDataTable(UIDataAdaptor).visitDataChildren(VisitContext, VisitCallback, boolean) line: 1282
      
      
      UIDataTable(UIDataTableBase).visitDataChildren(VisitContext, VisitCallback, boolean) line: 416
      
      
      UIDataTable(UIDataAdaptor).visitTree(VisitContext, VisitCallback) line: 1360
      
      
      HtmlForm(UIComponent).visitTree(VisitContext, VisitCallback) line: 1518
      
      
      HtmlForm(UIForm).visitTree(VisitContext, VisitCallback) line: 335
      
      
      UIOutput(UIComponent).visitTree(VisitContext, VisitCallback) line: 1518
      
      
      UIViewRoot(UIComponent).visitTree(VisitContext, VisitCallback) line: 1518
      
      
      ExtendedPartialViewContextImpl.visitActivatorComponent(String, VisitCallback, Set<VisitHint>) line: 474
      
      
      ExtendedPartialViewContextImpl.visitActivatorAtExecute() line: 335
      
      
      ExtendedPartialViewContextImpl.getExecuteIds() line: 98
      
      
      ExtendedPartialViewContextImpl.isExecuteAll() line: 148
      
      
      UIViewRoot.processDecodes(FacesContext) line: 922
      
      
      ApplyRequestValuesPhase.execute(FacesContext) line: 78
      
      
      ApplyRequestValuesPhase(Phase).doPhase(FacesContext, Lifecycle, ListIterator<PhaseListener>) line: 101
      
      
      LifecycleImpl.execute(FacesContext) line: 118
      
      
      
      FacesServlet.service(ServletRequest, ServletResponse) line: 508
      
      
        • 1. Re: ExtendedDataModel ajax call fail
          tehackio teha Newbie

          More information.

          I'm using richfaces 4.3.1.Final, apache-tomcat-7.0.34, servlet-weld 1.1.11.

           

          On org.richfaces.component.UIDataAdaptor, context.getFacesContext().getAttributes().get("javax.faces.visit.SKIP_ITERATION") returns "null", therefore "false".

           

              /**
               * @param context
               */
              private boolean requiresRowIteration(VisitContext context) {
                  // The VisitHint.SKIP_ITERATION enum is only available as of JSF 2.1.  Switch to using the enum when we no longer want to support JSF 2.0.
                  // return !context.getHints().contains(VisitHint.SKIP_ITERATION);
                  return ! Boolean.TRUE.equals(context.getFacesContext().getAttributes().get("javax.faces.visit.SKIP_ITERATION"));
              }