Package org.springmodules.xt.ajax.component

Examples of org.springmodules.xt.ajax.component.TaggedText


   
    private void renderErrorMessage(AjaxActionEvent event, AjaxResponse response, String messageCode, String defaultMessage) {
        // If errors occur, render an error message with a proper icon:
        String message = this.messageSource.getMessage(messageCode, null, defaultMessage, LocaleContextHolder.getLocale());
        Image img = new Image(event.getHttpRequest().getContextPath() + "/images/error.gif", "error");
        TaggedText txt = new TaggedText(message, TaggedText.Tag.SPAN);
        // Put the message in its proper web page space:
        ReplaceContentAction action1 = new ReplaceContentAction("message", img, txt);
        // Shake the message:
        Effect action2 = new Effect("Shake", "message");
        // Add actions to response:
View Full Code Here


    public AjaxResponse validateUsername(AjaxActionEvent event) {
        String username = event.getParameters().get("username");
        boolean exists = this.userService.checkUserAccount(username);
        AjaxResponse response = new AjaxResponseImpl("UTF-8");
        if (!exists) {
            TaggedText msg = new TaggedText(
                    this.messageSource.getMessage("user.available.username", null, "Available", LocaleContextHolder.getLocale()),
                    TaggedText.Tag.SPAN);
            msg.addAttribute("class", "okMessage");
           
            ReplaceContentAction action = new ReplaceContentAction("username.validation", msg);
           
            response.addAction(action);
        } else {
            TaggedText msg = new TaggedText(
                    this.messageSource.getMessage("user.unavailable.username", null, "Not Available", LocaleContextHolder.getLocale()),
                    TaggedText.Tag.SPAN);
            msg.addAttribute("class", "warnMessage");
           
            ReplaceContentAction action = new ReplaceContentAction("username.validation", msg);
           
            response.addAction(action);
        }
View Full Code Here

public class CustomValidationHandler extends DefaultValidationHandler {
   
    protected void afterValidation(AjaxSubmitEvent event, AjaxResponse response) {
        if (event.getValidationErrors() != null && event.getValidationErrors().hasErrors()) {
            Component errorImage = new Image(event.getHttpRequest().getContextPath() + "/images/error.gif", "error");
            Component errorMessage = new TaggedText(
                    this.messageSource.getMessage("message.error", null, "Error", LocaleContextHolder.getLocale()),
                    TaggedText.Tag.SPAN);
            AjaxAction removeAction = new RemoveContentAction("onSuccessMessage");
            AjaxAction replaceAction = new ReplaceContentAction("onErrorsMessage", errorImage, errorMessage);
            AjaxAction effectAction = new Effect("Shake", "onErrorsMessage");
View Full Code Here

        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);
View Full Code Here

    public AppendAsFirstContentActionTest(String testName) {
        super(testName);
    }
   
    public void testRender() throws Exception {
        AjaxAction action = new AppendAsFirstContentAction("testId", Arrays.asList(new Component[]{new TaggedText("Test Component 1", TaggedText.Tag.DIV), new TaggedText("Test Component 2", TaggedText.Tag.DIV)}));
       
        String result = action.render();
       
        System.out.println(result);
       
View Full Code Here

        assertXpathEvaluatesTo("testId", "/append-as-first-child/context/matcher/@contextNodeID", result);
    }
   
    public void testRenderWithListMatcher() throws Exception {
        ElementMatcher matcher = new ListMatcher(Arrays.asList("testId1", "testId2"));
        AjaxAction action = new AppendAsFirstContentAction(matcher, Arrays.asList(new Component[]{new TaggedText("Test Component 1", TaggedText.Tag.DIV), new TaggedText("Test Component 2", TaggedText.Tag.DIV)}));
       
        String result = action.render();
       
        System.out.println(result);
       
View Full Code Here

        assertXpathEvaluatesTo("testId1,testId2", "/append-as-first-child/context/matcher/@contextNodeID", result);
    }
   
    public void testRenderWithWildcardMatcher() throws Exception {
        ElementMatcher matcher = new WildcardMatcher("testId");
        AjaxAction action = new AppendAsFirstContentAction(matcher, Arrays.asList(new Component[]{new TaggedText("Test Component 1", TaggedText.Tag.DIV), new TaggedText("Test Component 2", TaggedText.Tag.DIV)}));
       
        String result = action.render();
       
        System.out.println(result);
       
View Full Code Here

        assertXpathEvaluatesTo("testId", "/append-as-first-child/context/matcher/@contextNodeID", result);
    }
   
    public void testRenderWithSelectorMatcher() throws Exception {
        ElementMatcher matcher = new SelectorMatcher(Arrays.asList("#testId1", "#testId2"));
        AjaxAction action = new AppendAsFirstContentAction(matcher, Arrays.asList(new Component[]{new TaggedText("Test Component 1", TaggedText.Tag.DIV), new TaggedText("Test Component 2", TaggedText.Tag.DIV)}));
       
        String result = action.render();
       
        System.out.println(result);
       
View Full Code Here

        return response;
    }
   
    public AjaxResponse insertAfter(AjaxActionEvent event) {
        // Create an ajax action for inserting content after:
        InsertContentAfterAction action = new InsertContentAfterAction("toInsertAfter", new TaggedText(", Spring Modules user", TaggedText.Tag.SPAN));
        // Disable the event:
        SetAttributeAction disableAction = new SetAttributeAction("insertAfterButton", "onclick", "");
       
        // Create a concrete ajax response:
        AjaxResponse response = new AjaxResponseImpl();
View Full Code Here

        return response;
    }
   
    public AjaxResponse insertBefore(AjaxActionEvent event) {
        // Create an ajax action for inserting content before:
        InsertContentBeforeAction action = new InsertContentBeforeAction("toInsertBefore", new TaggedText("Hello, ", TaggedText.Tag.SPAN));
        // Disable the event:
        SetAttributeAction disableAction = new SetAttributeAction("insertBeforeButton", "onclick", "");
       
        // Create a concrete ajax response:
        AjaxResponse response = new AjaxResponseImpl();
View Full Code Here

TOP

Related Classes of org.springmodules.xt.ajax.component.TaggedText

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.