Package org.apache.tapestry5.services

Examples of org.apache.tapestry5.services.BeanBlockSource


        "class", "t-autocomplete-menu");
        writer.end();

        Link link = resources.createEventLink(EVENT_NAME);

        JSONObject config = new JSONObject();
        config.put("paramName", PARAM_NAME);
        config.put("indicator", loaderId);

        if (resources.isBound("minChars"))
            config.put("minChars", minChars);

        if (resources.isBound("frequency"))
            config.put("frequency", frequency);

        if (resources.isBound("tokens"))
        {
            for (int i = 0; i < tokens.length(); i++)
            {
                config.accumulate("tokens", tokens.substring(i, i + 1));
            }
        }

        // Let subclasses do more.
        configure(config);
View Full Code Here


     * not formatted correct.
     */
    JSONObject onParse(@RequestParameter(INPUT_PARAMETER)
    String input)
    {
        JSONObject response = new JSONObject();

        try
        {
            Date date = format.parse(input);

            response.put(RESULT, date.getTime());
        }
        catch (ParseException ex)
        {
            response.put(ERROR, ex.getMessage());
        }

        return response;
    }
View Full Code Here

     * the result.
     */
    JSONObject onFormat(@RequestParameter(INPUT_PARAMETER)
    String input)
    {
        JSONObject response = new JSONObject();

        try
        {
            long millis = Long.parseLong(input);

            Date date = new Date(millis);

            response.put(RESULT, format.format(date));
        }
        catch (NumberFormatException ex)
        {
            response.put(ERROR, ex.getMessage());
        }

        return response;
    }
View Full Code Here

    public void no_editor_block_available()
    {
        PropertyModel model = mockPropertyModel();
        PropertyOverrides overrides = mockPropertyOverrides();
        ComponentResources resources = mockComponentResources();
        BeanBlockSource source = newMock(BeanBlockSource.class);
        RuntimeException exception = new RuntimeException("Simulated failure.");
        Messages messages = mockMessages();
        Location l = mockLocation();

        String propertyId = "foo";
        String dataType = "unk";
        String propertyName = "fooProp";
        Object object = "[OBJECT]";
        String formattedMessage = "formatted-message";

        expect(model.getId()).andReturn(propertyId);

        train_getOverrideBlock(overrides, propertyId, null);

        expect(model.getDataType()).andReturn(dataType);

        expect(source.getEditBlock(dataType)).andThrow(exception);
        expect(model.getPropertyName()).andReturn(propertyName);

        train_getLocation(resources, l);

        expect(messages.format("core-block-error", propertyName, dataType, object, exception))
View Full Code Here

    public void no_editor_block_available()
    {
        PropertyModel model = mockPropertyModel();
        ComponentResources overrides = mockComponentResources();
        ComponentResources resources = mockComponentResources();
        BeanBlockSource source = newMock(BeanBlockSource.class);
        RuntimeException exception = new RuntimeException("Simulated failure.");
        Messages messages = mockMessages();
        Location l = mockLocation();

        String propertyId = "foo";
        String dataType = "unk";
        String propertyName = "fooProp";
        Object object = "[OBJECT]";
        String formattedMessage = "formatted-message";

        expect(model.getId()).andReturn(propertyId);

        expect(overrides.getBlockParameter(propertyId)).andReturn(null);

        expect(model.getDataType()).andReturn(dataType);

        expect(source.getEditBlock(dataType)).andThrow(exception);
        expect(model.getPropertyName()).andReturn(propertyName);

        train_getLocation(resources, l);

        expect(messages.format("block-error", propertyName, dataType, object, exception))
View Full Code Here

        train_get(cache, "MyPage", page);
        train_getBlock(page, "mydisplay", block);

        replay();

        BeanBlockSource source = new BeanBlockSourceImpl(cache, createBeanBlockOverrideSource(cache), configuration);

        // Check case insensitivity while we are at it.
        assertTrue(source.hasDisplayBlock("MyData"));
        Block actual = source.getDisplayBlock("MyData");

        assertSame(actual, block);

        verify();
    }
View Full Code Here

        expect(overrideSource.hasDisplayBlock(datatype)).andReturn(true);
        expect(overrideSource.getDisplayBlock(datatype)).andReturn(block);

        replay();

        BeanBlockSource source = new BeanBlockSourceImpl(cache, overrideSource, EMPTY_CONFIGURATION);

        // Check case insensitivity while we are at it.
        assertTrue(source.hasDisplayBlock(datatype));
        Block actual = source.getDisplayBlock(datatype);

        assertSame(actual, block);

        verify();
    }
View Full Code Here

        RequestPageCache cache = mockRequestPageCache();
        Collection<BeanBlockContribution> configuration = newList();

        replay();

        BeanBlockSource source = new BeanBlockSourceImpl(cache, createBeanBlockOverrideSource(cache), configuration);

        try
        {
            assertFalse(source.hasDisplayBlock("MyData"));
            source.getDisplayBlock("MyData");
            unreachable();
        }
        catch (RuntimeException ex)
        {
            assertEquals(
View Full Code Here

        RequestPageCache cache = mockRequestPageCache();
        Collection<BeanBlockContribution> configuration = newList();

        replay();

        BeanBlockSource source = new BeanBlockSourceImpl(cache, createBeanBlockOverrideSource(cache), configuration);

        try
        {
            source.getEditBlock("MyData");
            unreachable();
        }
        catch (RuntimeException ex)
        {
            assertEquals(
View Full Code Here

        train_get(cache, "MyPage", page);
        train_getBlock(page, "mydisplay", block);

        replay();

        BeanBlockSource source = new BeanBlockSourceImpl(cache, createBeanBlockOverrideSource(cache), configuration);

        // Check case insensitivity while we are at it.
        Block actual = source.getEditBlock("MyData");

        assertSame(actual, block);

        verify();
    }
View Full Code Here

TOP

Related Classes of org.apache.tapestry5.services.BeanBlockSource

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.