Example #1
0
 public void cancel() {
   super.cancel(true);
   isCanceled = true;
   if (mAjax != null) {
     HttpRequest mHttpRequest = mAjax.getHttpRequest();
     if (mHttpRequest != null) {
       mHttpRequest.cancel();
       mHttpRequest = null;
     }
   }
 }
Example #2
0
  /**
   * RichFaces PartialViewContext implementation does not extend from PartialViewContextWrapper. So
   * a hack wherin the exact fully qualified class name needs to be known has to be used to properly
   * extract it from the {@link FacesContext#getPartialViewContext()}.
   *
   * @return The RichFaces PartialViewContext implementation.
   */
  public static PartialViewContext getRichFacesPartialViewContext() {
    PartialViewContext context = Ajax.getContext();

    while (!context.getClass().getName().equals(Hacks.RICHFACES_PVC_CLASS_NAME)
        && context instanceof PartialViewContextWrapper) {
      context = ((PartialViewContextWrapper) context).getWrapped();
    }

    if (context.getClass().getName().equals(Hacks.RICHFACES_PVC_CLASS_NAME)) {
      return context;
    } else {
      return null;
    }
  }
Example #3
0
  @SuppressWarnings("unchecked")
  @Override
  protected Object doInBackground(Ajax... ajaxs) {
    Object data = null;
    final Ajax ajax = mAjax;

    if (ajax == null) return null;

    HttpRequest mHttpRequest = ajax.getHttpRequest();
    if (ajax.getOnProgressListener() != null) {
      mHttpRequest.setOnProgressListener(this);
    }

    if (mAjax.getParser() == null && ajax.getOnSuccessListener() == null) {
      mHttpRequest.setIsNeedResponse(false);
    }

    isError = !mHttpRequest.send();

    if (!isError
        && !isCanceled
        && ajax.getOnSuccessListener() != null
        && mHttpRequest.getHttpStatus() == HttpStatus.SC_OK) {
      @SuppressWarnings("rawtypes")
      final Parser parser = mAjax.getParser();
      try {
        if (parser == null) {
          Log.e(LOG_TAG, "you have set onSuccessListener, but the parser is null");
        } else {
          data = parser.parse(mHttpRequest.getResponseData(), mHttpRequest.getCharset());
        }
      } catch (Exception ex) {
        if (null != parser && TextUtils.isEmpty(parser.getErrMsg())) {
          parser.setErrMsg(IcsonApplication.app.getString(R.string.parser_error_msg));
        }

        isError = true;
        if (Config.DEBUG) {
          Log.e(LOG_TAG, ToolUtil.getStackTraceString(ex));
        }
      }
    }

    return data;
  }
Example #4
0
 @Override
 protected void onPostExecute(Object data) {
   if (mAjax == null || isCanceled) return;
   mAjax.run(data);
 }
Example #5
0
 protected void onProgressUpdate(int[] values) {
   mAjax.performOnProgress(values[0], values[1]);
 }
Example #6
0
 @Override
 protected void onPreExecute() {
   mAjax.performOnBefore();
 }
Example #7
0
  @Override
  protected void onCancelled() {
    if (mAjax == null) return;

    mAjax.performOnCancel();
  }