Package org.apache.commons.chain.web

Examples of org.apache.commons.chain.web.ChainListener


      //contains a widget in the xmlns:acme="http://www.acme.org/widgets" namespace
        loadConfigFiles("/org/apache/shale/clay/config/altns-config.xml", null);
       
        // simulate invoking the common chains context listener
        servletContext.addInitParameter("org.apache.commons.chain.CONFIG_WEB_RESOURCE", "/org/apache/shale/clay/config/chain-config.xml");       
        ServletContextListener chainsListener = new ChainListener();
        ServletContextEvent servletContextEvent = new ServletContextEvent(servletContext);
        chainsListener.contextInitialized(servletContextEvent);
       
        // find the config bean definition in the commons XML config file
        ComponentBean configBean = standardConfigBean.getElement("acme:city");
        assertNotNull("acme:city exists", configBean);
        assertEquals("id", "city", configBean.getId());
       
        AttributeBean size = configBean.getAttribute("size");
        assertNotNull("size", size);
        assertEquals("size", "20", size.getValue());
       
        AttributeBean value = configBean.getAttribute("value");
        assertNotNull("value", value);
        assertEquals("value", "#{@managed-bean-name.city}", value.getValue());
       
        AttributeBean maxlength = configBean.getAttribute("maxlength");
        assertNotNull("maxlength", maxlength);
        assertEquals("maxlength", "30", maxlength.getValue());
       
        AttributeBean required = configBean.getAttribute("required");
        assertNotNull("required", required);
        assertEquals("required", "true", required.getValue());
      

        // load a template that points/extends the acme:city widget
        ComponentBean templateRoot = htmlTemplateConfigBean.getElement("/org/apache/shale/clay/config/altns.html");
        assertNotNull("/org/apache/shale/clay/config/altns.html",  templateRoot);
       
        // config bean after extend by the html template
        ComponentBean cityConfigBean = findForId(configBean.getId(), templateRoot);
        assertNotNull("city from html template", cityConfigBean);
       
        // inherit from acme:city
        assertEquals("id", "city", cityConfigBean.getId());
       
        // html override
        size = cityConfigBean.getAttribute("size");
        assertNotNull("size", size);
        assertEquals("size", "10", size.getValue());
       
        // inherit from acme:city
        value = cityConfigBean.getAttribute("value");
        assertNotNull("value", value);
        assertEquals("value", "#{@managed-bean-name.city}", value.getValue());
       
        // html override
        maxlength = cityConfigBean.getAttribute("maxlength");
        assertNotNull("maxlength", maxlength);
        assertEquals("maxlength", "100", maxlength.getValue());
       
        // html override
        required = cityConfigBean.getAttribute("required");
        assertNotNull("required", required);
        assertEquals("required", "false", required.getValue());
       
        // just because we can
        chainsListener.contextDestroyed(servletContextEvent);
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.chain.web.ChainListener

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.