Examples of AjaxCallListener


Examples of org.apache.wicket.ajax.attributes.AjaxCallListener

            @Override
            protected void updateAjaxAttributes(AjaxRequestAttributes attributes)
            {
              super.updateAjaxAttributes(attributes);
              AjaxCallListener ajaxCallListener = new AjaxCallListener() {
                @Override
                public CharSequence getFailureHandler(Component component)
                {
                  return "window.location=this.href;";
                }
View Full Code Here

Examples of org.apache.wicket.ajax.attributes.AjaxCallListener

      @Override
      protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
        super.updateAjaxAttributes(attributes);
        attributes.setDataType("json");
        attributes.setWicketAjaxResponse(false);
        attributes.getAjaxCallListeners().add(new AjaxCallListener().onSuccess("callback(data);"));
      }
     
      @Override
      public void renderHead(Component component, IHeaderResponse response) {
        super.renderHead(component, response);
        response.render(JavaScriptHeaderItem.forScript(
          "var fetchEventsFunc = "
            + this.getCallbackFunction(
              context("start")
              , context("end")
              , context("callback")
              , resolved("_start", "start.getTime()")
              , resolved("_end", "end.getTime()")) + ";"
          , "fetchEventsFunc"));
      }

      @Override
      protected void respond(AjaxRequestTarget target) {
        Calendar start = WebSession.getCalendar();
        start.setTimeInMillis(getRequestCycle().getRequest().getRequestParameters().getParameterValue("_start").toLong());
        Calendar end = WebSession.getCalendar();
        end.setTimeInMillis(getRequestCycle().getRequest().getRequestParameters().getParameterValue("_end").toLong());
        JSONArray events = new JSONArray();
        for (Appointment a : Application.getBean(AppointmentDao.class).getAppointmentsByRange(WebSession.getUserId(),
            start.getTime(), end.getTime())) {
          try {
            events.put(new JSONObject()
              .put("id", a.getAppointmentId())
              .put("title", a.getAppointmentName())
              .put("description", a.getAppointmentDescription())
              .put("start", WebSession.getDateFormat().format(a.getAppointmentStarttime()))
              .put("end", WebSession.getDateFormat().format(a.getAppointmentEndtime()))
              .put("allDay", false));
          } catch (JSONException e) {
            e.printStackTrace();
          }
        }
              getRequestCycle().scheduleRequestHandlerAfterCurrent(
                new TextRequestHandler("application/json", "UTF-8", events.toString()));
      }
    });
    //dropEvent
    add(new DropResizeBehavior(true, "dropEventFunc"));
    //resizeEvent
    add(new DropResizeBehavior(false, "resizeEventFunc"));
    //create on click-and-drag
    add(new AbstractDefaultAjaxBehavior() {
      private static final long serialVersionUID = 6880514947331946407L;

      @Override
      protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
        super.updateAjaxAttributes(attributes);
        attributes.getAjaxCallListeners().add(new AjaxCallListener().onSuccess("$('#appointment').dialog('open');"));
      }
     
      @Override
      public void renderHead(Component component, IHeaderResponse response) {
        super.renderHead(component, response);
        response.render(JavaScriptHeaderItem.forScript(
          "var selectFunc = "
            + this.getCallbackFunction(
              context("start")
              , context("end")
              , context("allDay")
              , context("jsEvent")
              , context("view")
              , resolved("_start", "start.getTime()")
              , resolved("_end", "end.getTime()")) + ";"
          , "selectFunc"));
      }

      @Override
      protected void respond(AjaxRequestTarget target) {
        Calendar start = WebSession.getCalendar();
        start.setTimeInMillis(getRequestCycle().getRequest().getRequestParameters().getParameterValue("_start").toLong());
        Calendar end = WebSession.getCalendar();
        end.setTimeInMillis(getRequestCycle().getRequest().getRequestParameters().getParameterValue("_end").toLong());
       
        if (start.equals(end)) {
          end.add(Calendar.HOUR_OF_DAY, 1);
        }
        Appointment a = new Appointment();
        a.setAppointmentStarttime(start.getTime());
        a.setAppointmentEndtime(end.getTime());
        form.setModelObject(a);
       
        target.add(form);
      }
    });
    //eventClick
    add(new AbstractDefaultAjaxBehavior() {
      private static final long serialVersionUID = 6880514947331946407L;

      @Override
      protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
        super.updateAjaxAttributes(attributes);
        attributes.getAjaxCallListeners().add(new AjaxCallListener().onSuccess("$('#appointment').dialog('open');"));
      }
     
      @Override
      public void renderHead(Component component, IHeaderResponse response) {
        super.renderHead(component, response);
View Full Code Here

Examples of org.apache.wicket.ajax.attributes.AjaxCallListener

    }
   
    @Override
    protected void updateAjaxAttributes(AjaxRequestAttributes attributes) {
      super.updateAjaxAttributes(attributes);
      attributes.getAjaxCallListeners().add(new AjaxCallListener().onFailure("revertFunc();"));
    }
View Full Code Here

Examples of org.apache.wicket.ajax.attributes.AjaxCallListener

      @Override
      protected void updateAjaxAttributes(AjaxRequestAttributes attributes)
      {
        super.updateAjaxAttributes(attributes);
        IAjaxCallListener ajaxCallListener = new AjaxCallListener() {
          @Override
          public CharSequence getBeforeSendHandler(Component component)
          {
            return "showLoadingIndicator();";
          }
View Full Code Here

Examples of org.apache.wicket.ajax.attributes.AjaxCallListener

   *
   * @param attributes
   */
  private void updateAjaxAttributesBackwardCompatibility(final AjaxRequestAttributes attributes)
  {
    AjaxCallListener backwardCompatibleAjaxCallListener = new AjaxCallListener();
    backwardCompatibleAjaxCallListener.onSuccess(getSuccessScript());
    backwardCompatibleAjaxCallListener.onFailure(getFailureScript());
    backwardCompatibleAjaxCallListener.onPrecondition(getPreconditionScript());
    attributes.getAjaxCallListeners().add(backwardCompatibleAjaxCallListener);

    AjaxChannel channel = getChannel();
    if (channel != null)
    {
View Full Code Here

Examples of org.apache.wicket.ajax.attributes.AjaxCallListener

        CharSequence precondition = "var kc=Wicket.Event.keyCode(attrs.event),"
          + "evtType=attrs.event.type,"
          + "ret=false;"
          + "if (evtType==='blur' || (evtType==='keyup' && kc===27) || (evtType==='keydown' && kc===13)) {attrs.event.preventDefault(); ret = true;}"
          + "return ret;";
        AjaxCallListener ajaxCallListener = new AjaxCallListener();
        ajaxCallListener.onPrecondition(precondition);

        CharSequence dynamicExtraParameters = "var result = [],"
          + "evtType=attrs.event.type;"
          + "if (evtType === 'keyup') { result.push( { name: 'save', value: false } ); }"
          + "else { result = Wicket.Form.serializeElement(attrs.c); result.push( { name: 'save', value: true } ); }"
View Full Code Here

Examples of org.apache.wicket.ajax.attributes.AjaxCallListener

            @Override
            protected void updateAjaxAttributes(AjaxRequestAttributes attributes)
            {
              super.updateAjaxAttributes(attributes);
              AjaxCallListener ajaxCallListener = new AjaxCallListener()
              {
                @Override
                public CharSequence getFailureHandler(Component component)
                {
                  return "window.location=this.href;";
View Full Code Here

Examples of org.apache.wicket.ajax.attributes.AjaxCallListener

      @Override
      protected void updateAjaxAttributes(AjaxRequestAttributes attributes)
      {
        super.updateAjaxAttributes(attributes);

        IAjaxCallListener ajaxCallListener = new AjaxCallListener() {
          @Override
          public CharSequence getSuccessHandler(Component component)
          {
            return "alert('Success');";
          }

          @Override
          public CharSequence getBeforeSendHandler(Component component)
          {
            return "alert('Before ajax call');";
          }

          @Override
          public CharSequence getFailureHandler(Component component)
          {
            return "alert('Failure');";
          }
        };
        attributes.getAjaxCallListeners().add(ajaxCallListener);

        List<CharSequence> urlArgumentMethods = attributes.getDynamicExtraParameters();
        urlArgumentMethods.add("return {'htmlname': document.documentElement.tagName};");
        urlArgumentMethods.add("return {'bodyname': document.body.tagName};");
      }
    });

    add(new AjaxLink<Void>("failure-link")
    {
      @Override
      public void onClick(AjaxRequestTarget target)
      {
        // Set the proper setting to execute ajax failure handler
        // note: will be set until the "exception" link is clicked or the application is
        // restarted
        getApplication().getExceptionSettings().setAjaxErrorHandlingStrategy(
          ExceptionSettings.AjaxErrorStrategy.INVOKE_FAILURE_HANDLER);

        throw new WicketRuntimeException("Failure link clicked");
      }

      @Override
      protected void updateAjaxAttributes(AjaxRequestAttributes attributes)
      {
        super.updateAjaxAttributes(attributes);
       
        IAjaxCallListener ajaxCallListener = new AjaxCallListener() {
          @Override
          public CharSequence getBeforeHandler(Component component)
          {
            return "alert('Before ajax call');";
          }
View Full Code Here

Examples of org.apache.wicket.ajax.attributes.AjaxCallListener

            @Override
            protected void updateAjaxAttributes(final AjaxRequestAttributes attributes) {
                super.updateAjaxAttributes(attributes);

                final AjaxCallListener ajaxCallListener = new AjaxCallListener() {

                    private static final long serialVersionUID = 7160235486520935153L;

                    @Override
                    public CharSequence getPrecondition(final Component component) {
View Full Code Here

Examples of org.apache.wicket.ajax.attributes.AjaxCallListener

  @Test
  public void renderAjaxAttributes()
  {
    AjaxRequestAttributes attributes = new AjaxRequestAttributes();

    AjaxCallListener listener = new AjaxCallListener();
    listener.onPrecondition("return somePrecondition();");
    listener.onBefore("alert('Before!');");
    listener.onAfter("alert('After!');");
    listener.onSuccess("alert('Success!');");
    listener.onFailure("alert('Failure!');");
    listener.onComplete("alert('Complete!');");
    attributes.getAjaxCallListeners().add(listener);

    Component component = Mockito.mock(Component.class);
    AbstractDefaultAjaxBehavior behavior = new AbstractDefaultAjaxBehavior()
    {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.