Package org.apache.myfaces.config.impl.digester.elements

Examples of org.apache.myfaces.config.impl.digester.elements.ManagedBean


     * This test is to test the view scope, introduced in jsf 2.0.
     */
    public void testIsInValidScopeViewScope()
    {
        // create viewBean referencing requestBean
        ManagedBean viewBean = new ManagedBean();
        viewBean.setBeanClass(TestBean.class.getName());
        viewBean.setName("viewBean");
        viewBean.setScope("view");
        ManagedProperty anotherBeanProperty = new ManagedProperty();
        anotherBeanProperty.setPropertyName("anotherBean");
        anotherBeanProperty.setValue("#{requestBean}");
        viewBean.addProperty(anotherBeanProperty);
        runtimeConfig.addManagedBean("viewBean", viewBean);
       
        // create requestBean
        ManagedBean requestBean = new ManagedBean();
        requestBean.setBeanClass(TestBean.class.getName());
        requestBean.setName("requestBean");
        requestBean.setScope("request");
        runtimeConfig.addManagedBean("requestBean", requestBean);
       
        try
        {
            new MockValueExpression("#{viewBean}", TestBean.class).getValue(facesContext.getELContext());
View Full Code Here


    protected void setUp() throws Exception
    {
        super.setUp();
        managedBeanBuilder  = new ManagedBeanBuilder();
       
        beanConfiguration = new ManagedBean();       
        beanConfiguration.setBeanClass(AnnotatedManagedBean2.class.getName());
        beanConfiguration.setName("managed");
        beanConfiguration.setScope("request");
       
        ManagedProperty managedProperty = new ManagedProperty();
View Full Code Here

   
    protected void setUp() throws Exception
  {
        super.setUp();
        ManagedBeanBuilder managedBeanBuilder = new ManagedBeanBuilder();
        ManagedBean managedBean = new ManagedBean();
       
        managedBean.setBeanClass(MangedBeanExample.class.getName());
        managedBean.setName("managed");
        managedBean.setScope("request");
       
        // test methods of children will want to make sure these values come
        // out on the other end of this.
        MANAGED_LIST.add("0");
        MANAGED_LIST.add("1");
        MANAGED_LIST.add("2");
        MANAGED_MAP.put("0", "0");
        MANAGED_MAP.put("1", "1");
        MANAGED_MAP.put("2", "2");
       
        ManagedProperty managedProperty = new ManagedProperty();
        managedProperty.setPropertyName("managedProperty");
        managedProperty.setValue(INJECTED_VALUE);
       
        ManagedProperty managedList = new ManagedProperty();
        managedList.setPropertyName("managedList");
        ListEntries listEntries = makeListEntries();
        managedList.setListEntries(listEntries);
       
        ManagedProperty writeOnlyList = new ManagedProperty();
        writeOnlyList.setPropertyName("writeOnlyList");
        ListEntries writeOnlyListEntries = makeListEntries();
        writeOnlyList.setListEntries(writeOnlyListEntries);
       
        ManagedProperty managedMap = new ManagedProperty();
        managedMap.setPropertyName("managedMap");
        MapEntries mapEntries = makeMapEntries();
        managedMap.setMapEntries(mapEntries);
       
        ManagedProperty writeOnlyMap = new ManagedProperty();
        writeOnlyMap.setPropertyName("writeOnlyMap");
        MapEntries writeOnlyMapEntries = makeMapEntries();
        writeOnlyMap.setMapEntries(writeOnlyMapEntries);       
       
        managedBean.addProperty(managedProperty);
        managedBean.addProperty(managedList);
        managedBean.addProperty(writeOnlyList);
        managedBean.addProperty(managedMap);
        managedBean.addProperty(writeOnlyMap);

        // simulate a managed bean creation
        example = (MangedBeanExample) managedBeanBuilder
            .buildManagedBean(facesContext, managedBean);
    }
View Full Code Here

     * the session, the application and the none scope.
     */
    public void testIsInValidScope()
    {
        // create sessionBean referencing requestBean
        ManagedBean sessionBean = new ManagedBean();
        sessionBean.setBeanClass(TestBean.class.getName());
        sessionBean.setName("sessionBean");
        sessionBean.setScope("session");
        ManagedProperty anotherBeanProperty = new ManagedProperty();
        anotherBeanProperty.setPropertyName("anotherBean");
        anotherBeanProperty.setValue("#{requestBean}");
        sessionBean.addProperty(anotherBeanProperty);
        runtimeConfig.addManagedBean("sessionBean", sessionBean);
       
        // create requestBean
        ManagedBean requestBean = new ManagedBean();
        requestBean.setBeanClass(TestBean.class.getName());
        requestBean.setName("requestBean");
        requestBean.setScope("request");
        runtimeConfig.addManagedBean("requestBean", requestBean);
       
        try
        {
            new MockValueExpression("#{sessionBean}", TestBean.class).getValue(facesContext.getELContext());
View Full Code Here

     */
    @SuppressWarnings("unchecked")
    public void testCustomScope()
    {
        // create the custom scope
        ManagedBean scopeBean = new ManagedBean();
        scopeBean.setBeanClass(HashMap.class.getName());
        scopeBean.setName("scopeBean");
        scopeBean.setScope("application");
        runtimeConfig.addManagedBean("scopeBean", scopeBean);
       
        // create the managed bean
        ManagedBean beanInCustomScope = new ManagedBean();
        beanInCustomScope.setBeanClass(ArrayList.class.getName());
        beanInCustomScope.setName("beanInCustomScope");
        beanInCustomScope.setScope("#{scopeBean}");
        runtimeConfig.addManagedBean("beanInCustomScope", beanInCustomScope);
       
        // resolve the managed bean
        Object resolvedBeanInCustomScope = new MockValueExpression("#{beanInCustomScope}", List.class)
                                                   .getValue(facesContext.getELContext());
View Full Code Here

     * of the value, and the type of the value.
     */
    public void testCustomScopeNoMap()
    {
        // create the custom scope
        ManagedBean scopeBean = new ManagedBean();
        // Scope is ArrayList instead of HashMap
        scopeBean.setBeanClass(ArrayList.class.getName());
        scopeBean.setName("scopeBean");
        scopeBean.setScope("application");
        runtimeConfig.addManagedBean("scopeBean", scopeBean);
       
        // create the managed bean
        ManagedBean beanInCustomScope = new ManagedBean();
        beanInCustomScope.setBeanClass(ArrayList.class.getName());
        beanInCustomScope.setName("beanInCustomScope");
        beanInCustomScope.setScope("#{scopeBean}");
        runtimeConfig.addManagedBean("beanInCustomScope", beanInCustomScope);
       
        // resolve the managed bean
        try
        {
            new MockValueExpression("#{beanInCustomScope}", List.class)
                    .getValue(facesContext.getELContext());
        }
        catch (FacesException fe)
        {
            // the message must contain ...
            final String message = fe.getMessage();
            // ... the expression string
            assertTrue(message.contains(beanInCustomScope.getManagedBeanScope()));
            Object resolvedScopeBean = new MockValueExpression("#{scopeBean}", List.class)
                                               .getValue(facesContext.getELContext());
            // ... the toString() of the value
            assertTrue(message.contains(resolvedScopeBean.toString()));
            // ... and the type of the value
View Full Code Here

     * The ManagedBeanResolver only tries to detect cyclic references if ProjectStage != Production.
     */
    public void testCustomScopeCyclicReferences()
    {
        // create m1
        ManagedBean m1 = new ManagedBean();
        m1.setBeanClass(TestBean.class.getName());
        m1.setName("m1");
        m1.setScope("#{m2.scope}");
        runtimeConfig.addManagedBean("m1", m1);
       
        // create m2
        ManagedBean m2 = new ManagedBean();
        m2.setBeanClass(TestBean.class.getName());
        m2.setName("m2");
        m2.setScope("#{m1.scope}");
        runtimeConfig.addManagedBean("m2", m2);
       
        // try to resolve m1
        try
        {
View Full Code Here

     * Tests the view scope, which was introduced in jsf 2.0
     */
    public void testViewScope()
    {
        // create the managed bean
        ManagedBean beanInViewScope = new ManagedBean();
        beanInViewScope.setBeanClass(ArrayList.class.getName());
        beanInViewScope.setName("beanInViewScope");
        beanInViewScope.setScope("view");
        runtimeConfig.addManagedBean("beanInViewScope", beanInViewScope);
       
        // resolve the managed bean
        Object resolvedBeanInCustomScope = new MockValueExpression("#{beanInViewScope}", List.class)
                                                   .getValue(facesContext.getELContext());
View Full Code Here

    protected void setUp() throws Exception
    {
        super.setUp();
        managedBeanBuilder  = new ManagedBeanBuilder();
       
        beanConfiguration = new ManagedBean();       
        beanConfiguration.setBeanClass(AnnotatedManagedBean2.class.getName());
        beanConfiguration.setName("managed");
        beanConfiguration.setScope("request");
       
        ManagedProperty managedProperty = new ManagedProperty();
View Full Code Here

TOP

Related Classes of org.apache.myfaces.config.impl.digester.elements.ManagedBean

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.