Package org.apache.myfaces.extensions.cdi.message.api

Examples of org.apache.myfaces.extensions.cdi.message.api.MessageContext


    }

    @Test
    public void cloneMessageContextTest()
    {
        MessageContext messageContext = this.messageContext.cloneContext();
        messageContext.message().text("{hello}").create();

        this.messageContext.config().change().addMessageHandler(new TestInMemoryMessageHandler());

        assertFalse(messageContext.config().getMessageHandler().equals(this.messageContext.config().getMessageHandler()));
    }
View Full Code Here


    }

    @Test
    public void customMessageContextTest()
    {
        MessageContext messageContext = new TestCustomMessageContext();

        assertTrue(messageContext.typed(TestCustomMessageContext.class).isReachable());
    }
View Full Code Here

                .handleNavigation(facesContext, null, errorPage.getName());
    }

    private static void addViolationsAsMessage(Set<SecurityViolation> violations)
    {
        MessageContext messageContext = getContextualReferenceByClass(
                MessageContext.class, true, JSF_QUALIFIER);

        if(messageContext == null)
        {
            return;
        }

        for(SecurityViolation violation : violations)
        {
            messageContext.message().text(violation.getReason()).payload(MessageSeverity.ERROR).add();
        }
    }
View Full Code Here

        if (!argumentFilterInstance.isUnsatisfied())
        {
            argumentFilter = argumentFilterInstance.get();
        }

        MessageContext result = defaultMessageContext.config()
                .use()
                    .localeResolver(new JsfAwareLocaleResolver())
                    .messageResolver(new JsfAwareApplicationMessagesMessageResolver())
                    .messageInterpolator(new FacesMessageInterpolator(elProvider, argumentFilter))
                    .addMessageHandler(new JsfAwareMessageHandler())
                .create();

        if (messageFactory != null)
        {
            return DefaultMessageContext.create(result.config(), messageFactory);
        }

        return result;
    }
View Full Code Here

        if (!argumentFilterInstance.isUnsatisfied())
        {
            argumentFilter = argumentFilterInstance.get();
        }

        MessageContext result = defaultMessageContext.config()
                .use()
                    .localeResolver(new JsfAwareLocaleResolver())
                    .messageResolver(new JsfAwareApplicationMessagesMessageResolver())
                    .messageInterpolator(new FacesMessageInterpolator(elProvider, argumentFilter))
                    .addMessageHandler(new JsfAwareMessageHandler())
                .create();

        if (messageFactory != null)
        {
            return DefaultMessageContext.create(result.config(), messageFactory);
        }

        return result;
    }
View Full Code Here

                .handleNavigation(facesContext, null, errorPage.getName());
    }

    private static void addViolationsAsMessage(Set<SecurityViolation> violations)
    {
        MessageContext messageContext = getContextualReferenceByClass(
                MessageContext.class, true, JSF_QUALIFIER);

        if(messageContext == null)
        {
            return;
        }

        for(SecurityViolation violation : violations)
        {
            messageContext.message().text(violation.getReason()).payload(MessageSeverity.ERROR).add();
        }
    }
View Full Code Here

        if (!argumentFilterInstance.isUnsatisfied())
        {
            argumentFilter = argumentFilterInstance.get();
        }

        MessageContext result = defaultMessageContext.config()
                .use()
                .localeResolver(new JsfAwareLocaleResolver())
                .messageResolver(new JsfAwareApplicationMessagesMessageResolver())
                .messageInterpolator(new FacesMessageInterpolator(elProvider, argumentFilter))
                .addMessageHandler(new JsfAwareMessageHandler())
                .create();

        if (messageFactory != null)
        {
            return DefaultMessageContext.create(result.config(), messageFactory);
        }

        return result;
    }
View Full Code Here

    }

    @Test
    public void newContextTest()
    {
        MessageContext newMessageContext = this.messageContext.cloneContext();

        this.messageContext.config().change().localeResolver(new TestGermanLocaleResolver());
        newMessageContext.config().change().localeResolver(new TestEnglishLocaleResolver());

        if (newMessageContext.equals(this.messageContext))
        {
            fail("different context expected - old context: " + this.messageContext.toString() + " new context: " + newMessageContext.toString());
        }

        assertEquals(Locale.GERMAN, this.messageContext.config().getLocaleResolver().getLocale());
        assertEquals(Locale.ENGLISH, newMessageContext.config().getLocaleResolver().getLocale());
    }
View Full Code Here

    }

    @Test
    public void usedMessageResolverTest()
    {
        MessageContext newMessageContext = this.messageContext.config().use().localeResolver(new TestGermanLocaleResolver()).create();

        if (newMessageContext.equals(this.messageContext))
        {
            fail("different context expected - old context: " + this.messageContext.toString() + " new context: " + newMessageContext.toString());
        }
    }
View Full Code Here

    }

    @Test
    public void changedMessageResolverTest()
    {
        MessageContext messageContext = this.messageContext.config().change().localeResolver(new TestGermanLocaleResolver()).create();

        assertEquals(this.messageContext, messageContext);
    }
View Full Code Here

TOP

Related Classes of org.apache.myfaces.extensions.cdi.message.api.MessageContext

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.