Package org.springmodules.xt.ajax

Examples of org.springmodules.xt.ajax.AjaxResponse


        Exception ex = new Exception("exception");
       
        RedirectExceptionHandler handler = new RedirectExceptionHandler();
        handler.setRedirectUrl("/ajax/exception.action");
       
        AjaxResponse response = handler.handle(httpRequest, ex);
        assertNotNull(response);
        assertXpathExists("//redirect/content/target/@url", response.render());
    }
View Full Code Here


        assertTrue(httpResponse.getContentAsString().contains(text));
    }
   
    public void testSendResponseWithI18nCharsSucceeds() throws Exception {
        MockHttpServletResponse httpResponse = new MockHttpServletResponse();
        AjaxResponse ajaxResponse = new AjaxResponseImpl("UTF-8");
       
        String text = "questo è un semplice testo";
       
        ajaxResponse.addAction(new ReplaceContentAction("test", new SimpleText(text)));
       
        this.sender.sendResponse(httpResponse, ajaxResponse);
       
        assertTrue(httpResponse.getContentAsString().contains(text));
    }
View Full Code Here

        this.submitEvent = new AjaxSubmitEventImpl("submitEvent", request);
        this.submitEvent.setCommandObject(target);
    }
   
    public void testValidateWithErrorsPart1() throws Exception {
        AjaxResponse response = null;
        String rendering = null;
        DefaultValidationHandler handler = new DefaultValidationHandler();
        handler.setMessageSource(new DelegatingMessageSource());
       
        // Errors:
        this.submitEvent.setValidationErrors(this.errors);
       
        response = handler.validate(submitEvent);
        rendering = response.render();
        System.out.println(rendering);
       
        assertXpathEvaluatesTo("Default Message 1", "//append-as-children/content/div", rendering);
        assertXpathEvaluatesTo("wildcard", "//append-as-children/context/matcher/@matchMode", rendering);
        assertXpathExists("//execute-javascript/content/script", rendering);
View Full Code Here

        assertXpathExists("//execute-javascript/content/script", rendering);
        assertTrue(rendering.indexOf("new Effect.Highlight(\"ErrorCode1\",{\"startcolor\":\"#FF0A0A\"});") != -1);
    }
   
    public void testValidateWithErrorsPart2() throws Exception {
        AjaxResponse response = null;
        String rendering = null;
        DefaultValidationHandler handler = new DefaultValidationHandler();
        handler.setMessageSource(new DelegatingMessageSource());
        handler.setErrorRenderingCallback(new DefaultErrorRenderingCallback() {
            public Component getErrorComponent(AjaxSubmitEvent event, ObjectError error, MessageSource messageSource, Locale locale) {
                return new TaggedText(messageSource.getMessage(error.getCode(), null, error.getDefaultMessage() + " for event : " + event.getEventId(), locale), TaggedText.Tag.SPAN);
            }
        });
       
        // Errors:
        this.submitEvent.setValidationErrors(this.errors);
       
        response = handler.validate(submitEvent);
        rendering = response.render();
        System.out.println(rendering);
       
        assertXpathEvaluatesTo("Default Message 1 for event : submitEvent", "//append-as-children/content/span", rendering);
        assertXpathEvaluatesTo("wildcard", "//append-as-children/context/matcher/@matchMode", rendering);
        assertXpathExists("//execute-javascript/content/script", rendering);
View Full Code Here

        assertXpathExists("//execute-javascript/content/script", rendering);
        assertTrue(rendering.indexOf("new Effect.Highlight(\"ErrorCode1\",{\"startcolor\":\"#FF0A0A\"});") != -1);
    }
   
    public void testValidateWithNoErrorsPart1() throws Exception {
        AjaxResponse response = null;
        String rendering = null;
        DefaultValidationHandler handler = new DefaultValidationHandler();
        handler.setMessageSource(new DelegatingMessageSource());
       
        response = handler.validate(submitEvent);
        rendering = response.render();
        System.out.println(rendering);
       
        assertXpathNotExists("/ajax-response/*", rendering);
    }
View Full Code Here

        }
        // Create an ajax action for replacing the content of the "offices" element with the components just created:
        ReplaceContentAction action = new ReplaceContentAction("offices", options);
       
        // Create a concrete ajax response:
        AjaxResponse response = new AjaxResponseImpl();
        // Add the action:
        response.addAction(action);
       
        return response;
    }
View Full Code Here

        // Create an ajax action for appending the new row:
        AppendContentAction appendRowAction = new AppendContentAction("employees", row);

        // Create a concrete ajax response:
        AjaxResponse response = new AjaxResponseImpl();
        // Add actions:
        response.addAction(appendRowAction);

        return response;
    }
View Full Code Here

        }
        // Create an ajax action for replacing the old table body content, inserting these new rows:
        ReplaceContentAction replaceRowsAction = new ReplaceContentAction("employees", rows);
       
        // Create a concrete ajax response:
        AjaxResponse response = new AjaxResponseImpl();
        // Add actions:
        response.addAction(setMessageAction);
        response.addAction(highlightAction);
        response.addAction(replaceRowsAction);
       
        return response;
    }
View Full Code Here

            ListItem item = new ListItem(new SimpleText(draggedEmployee.getFirstname() + " " + draggedEmployee.getSurname()));
            InputField hidden = new InputField(helper.getStatusExpression(), draggedEmployee.getMatriculationCode(), InputField.InputType.HIDDEN);
           
            AppendContentAction appendAction = new AppendContentAction("employees", new LinkedList<Component>(Arrays.asList(item, hidden)));
           
            AjaxResponse response = new AjaxResponseImpl();
            response.addAction(appendAction);
           
            return response;
        }
        else {
            return null;
View Full Code Here

        SimpleText text = new SimpleText(number + "&#160;&#160;&#160;");
        // Create an ajax action for appending it:
        AppendContentAction action = new AppendContentAction("num", text);
       
        // Create a concrete ajax response:
        AjaxResponse response = new AjaxResponseImpl();
        // Add the action:
        response.addAction(action);
       
        return response;
    }
View Full Code Here

TOP

Related Classes of org.springmodules.xt.ajax.AjaxResponse

Copyright © 2018 www.massapicom. 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.