Package org.apache.tapestry.form

Examples of org.apache.tapestry.form.ValidatableFieldSupport


public class TestDropdownTimePicker extends BaseFormComponentTestCase
{
   
    public void test_Render()
    {
        ValidatableFieldSupport vfs = newMock(ValidatableFieldSupport.class);
        DateTranslator translator = new DateTranslator();
        translator.setPattern("hh:mm a");
        ResponseBuilder resp = newMock(ResponseBuilder.class);
       
        IRequestCycle cycle = newMock(IRequestCycle.class);
        IForm form = newMock(IForm.class);
        checkOrder(form, false);
        IPage page = newPage();
        Locale locale = Locale.getDefault();
       
        MockDelegate delegate = new MockDelegate();
       
        IScript script = newMock(IScript.class);
       
        Date dtValue = new Date();
       
        DropdownTimePicker component = newInstance(DropdownTimePicker.class,
                new Object[] {
            "name", "fred",
            "script", script,
            "validatableFieldSupport", vfs,
            "translator", translator,
            "value", dtValue,
            "page", page
        });
       
        expect(cycle.renderStackPush(component)).andReturn(component);
       
        expect(form.getName()).andReturn("testform").anyTimes();
       
        form.setFormFieldUpdating(true);
       
        IMarkupWriter writer = newBufferWriter();
       
        trainGetForm(cycle, form);
        trainWasPrerendered(form, writer, component, false);
       
        trainGetDelegate(form, delegate);
       
        delegate.setFormComponent(component);
       
        trainGetElementId(form, component, "fred");
        trainIsRewinding(form, false);
        expect(cycle.isRewinding()).andReturn(false).anyTimes();
       
        delegate.setFormComponent(component);
       
        expect(cycle.getResponseBuilder()).andReturn(resp).anyTimes();
        expect(resp.isDynamic()).andReturn(false).anyTimes();
       
        vfs.renderContributions(component, writer, cycle);

        expect(page.getLocale()).andReturn(locale).anyTimes();

        PageRenderSupport prs = newPageRenderSupport();
        trainGetPageRenderSupport(cycle, prs);
View Full Code Here


    }
   
    public void test_Rewind()
    {
        IAutocompleteModel model = createModel();
        ValidatableFieldSupport vfs = newMock(ValidatableFieldSupport.class);
        DataSqueezer ds = newMock(DataSqueezer.class);
       
        Autocompleter component = newInstance(Autocompleter.class,
                new Object[] { "model", model, "validatableFieldSupport", vfs,
            "dataSqueezer", ds});
       
        IRequestCycle cycle = newMock(IRequestCycle.class);
        IForm form = newMock(IForm.class);
       
        IMarkupWriter writer = newWriter();
       
        IValidationDelegate delegate = newDelegate();
       
        expect(cycle.renderStackPush(component)).andReturn(component);
       
        trainGetForm(cycle, form);
        trainWasPrerendered(form, writer, component, false);
        trainGetDelegate(form, delegate);
       
        delegate.setFormComponent(component);
       
        trainGetElementId(form, component, "barney");
        trainIsRewinding(form, true);
       
        trainGetParameter(cycle, "barney", "1");
       
        expect(ds.unsqueeze("1")).andReturn(new Integer(1));
       
        SimpleBean match = new SimpleBean(new Integer(1), null, -1);
       
        try
        {
            vfs.validate(component, writer, cycle, match);
        }
        catch (ValidatorException e)
        {
            unreachable();
        }
View Full Code Here

   
    @Test(dataProvider = "renderings")
    public void test_Render(String outcome, Boolean local)
    {          
        IAutocompleteModel model = createModel();
        ValidatableFieldSupport vfs = newMock(ValidatableFieldSupport.class);
        DataSqueezer ds = newMock(DataSqueezer.class);
        ResponseBuilder resp = newMock(ResponseBuilder.class);
       
        IRequestCycle cycle = newMock(IRequestCycle.class);
        IForm form = newMock(IForm.class);
        checkOrder(form, false);
       
        MockDelegate delegate = new MockDelegate();
       
        IEngineService engine = newEngineService();
        ILink link = newLink();
       
        IScript script = newMock(IScript.class);
       
        SimpleBean match = new SimpleBean(new Integer(2), "Simple 2", 200);
       
        Autocompleter component = newInstance(Autocompleter.class,
                new Object[] {
            "name", "fred", "model", model,
            "directService", engine,
            "script", script,
            "validatableFieldSupport", vfs,
            "value", match,
            "dataSqueezer", ds, "local", local
        });
       
        expect(cycle.renderStackPush(component)).andReturn(component);
       
        expect(form.getName()).andReturn("testform").anyTimes();
       
        form.setFormFieldUpdating(true);
       
        IMarkupWriter writer = newBufferWriter();
       
        DirectServiceParameter dsp =
            new DirectServiceParameter(component);
       
        trainGetForm(cycle, form);
        trainWasPrerendered(form, writer, component, false);
       
        trainGetDelegate(form, delegate);
       
        delegate.setFormComponent(component);
       
        trainGetElementId(form, component, "fred");
        trainIsRewinding(form, false);
        expect(cycle.isRewinding()).andReturn(false).anyTimes();
       
        delegate.setFormComponent(component);
       
        expect(cycle.getResponseBuilder()).andReturn(resp).anyTimes();
        expect(resp.isDynamic()).andReturn(false).anyTimes();
       
        vfs.renderContributions(component, writer, cycle);
        if (!local.booleanValue())
        {
            trainGetLinkCheckIgnoreParameter(engine, cycle, true, dsp, link);       
            trainGetURL(link, "urlstring");
        }
View Full Code Here

        assertEquals(json.get("3"), "Simple 3");
    }
   
    public void test_Is_Required()
    {
        ValidatableFieldSupport support = newMock(ValidatableFieldSupport.class);
       
        Autocompleter field = newInstance(Autocompleter.class,
                new Object[] { "validatableFieldSupport", support, });
       
        expect(support.isRequired(field)).andReturn(true);
       
        replay();
       
        assert field.isRequired();
View Full Code Here

        ILink link = newMock(ILink.class);
        IScript script = newMock(IScript.class);
        PageRenderSupport prs = newMock(PageRenderSupport.class);

        TranslatedFieldSupport translator = newMock(TranslatedFieldSupport.class);
        ValidatableFieldSupport validator = newMock(ValidatableFieldSupport.class);

        IValidationDelegate delegate = new ValidationDelegate();
        IForm form = newMock(IForm.class);
        IMarkupWriter writer = newBufferWriter();

        Suggest comp = newInstance(Suggest.class,
                                   "response", resp,
                                   "templateTagName", "input",
                                   "name", "suggest",
                                   "clientId", "suggest",
                                   "form", form,
                                   "translatedFieldSupport", translator,
                                   "validatableFieldSupport", validator,
                                   "engineService", engine,
                                   "script", script);

        expect(cycle.isRewinding()).andReturn(false).anyTimes();
        expect(resp.isDynamic()).andReturn(false);
        expect(cycle.getAttribute(TapestryUtils.FORM_ATTRIBUTE)).andReturn(form).anyTimes();

        expect(form.wasPrerendered(writer, comp)).andReturn(false).anyTimes();
        expect(form.getDelegate()).andReturn(delegate).anyTimes();
        expect(form.getElementId(comp)).andReturn("suggest");
        expect(form.isRewinding()).andReturn(false).anyTimes();

        form.setFormFieldUpdating(true);
       
        expect(translator.format(comp, null)).andReturn("r2d2");
        translator.renderContributions(comp, writer, cycle);
        validator.renderContributions(comp, writer, cycle);

        expect(cycle.getEngine()).andReturn(cengine);
        expect(cengine.getOutputEncoding()).andReturn("utf-8");
        expect(engine.getLink(eq(false), isA(DirectServiceParameter.class))).andReturn(link);
        expect(link.getURL()).andReturn("http://url");
View Full Code Here

        ILink link = newMock(ILink.class);
        IScript script = newMock(IScript.class);
        PageRenderSupport prs = newMock(PageRenderSupport.class);

        TranslatedFieldSupport translator = newMock(TranslatedFieldSupport.class);
        ValidatableFieldSupport validator = newMock(ValidatableFieldSupport.class);

        IValidationDelegate delegate = new ValidationDelegate();
        IForm form = newMock(IForm.class);
        IMarkupWriter writer = newBufferWriter();

        Suggest comp = newInstance(Suggest.class,
                                   "response", resp,
                                   "templateTagName", "textarea",
                                   "name", "suggest",
                                   "clientId", "suggest",
                                   "form", form,
                                   "translatedFieldSupport", translator,
                                   "validatableFieldSupport", validator,
                                   "engineService", engine,
                                   "script", script);

        expect(cycle.isRewinding()).andReturn(false).anyTimes();
        expect(resp.isDynamic()).andReturn(false);
        expect(cycle.getAttribute(TapestryUtils.FORM_ATTRIBUTE)).andReturn(form).anyTimes();

        expect(form.wasPrerendered(writer, comp)).andReturn(false).anyTimes();
        expect(form.getDelegate()).andReturn(delegate).anyTimes();
        expect(form.getElementId(comp)).andReturn("suggest");
        expect(form.isRewinding()).andReturn(false).anyTimes();

        form.setFormFieldUpdating(true);

        expect(translator.format(comp, null)).andReturn("r2d2");
        translator.renderContributions(comp, writer, cycle);
        validator.renderContributions(comp, writer, cycle);

        expect(cycle.getEngine()).andReturn(cengine);
        expect(cengine.getOutputEncoding()).andReturn("utf-8");
        expect(engine.getLink(eq(false), isA(DirectServiceParameter.class))).andReturn(link);
        expect(link.getURL()).andReturn("http://url");
View Full Code Here

        IRequestCycle cycle = newMock(IRequestCycle.class);
        checkOrder(cycle, false);
        ResponseBuilder resp = newMock(ResponseBuilder.class);

        TranslatedFieldSupport translator = newMock(TranslatedFieldSupport.class);
        ValidatableFieldSupport validator = newMock(ValidatableFieldSupport.class);

        IValidationDelegate delegate = new ValidationDelegate();
        IForm form = new MockForm(delegate);
        IMarkupWriter writer = newBufferWriter();

        IBinding binding = newMock(IBinding.class);
        Location l = newLocation();
        ComponentSpecification spec = new ComponentSpecification();
       
        Suggest comp = newInstance(Suggest.class,
                                   "response", resp,
                                   "templateTagName", "input",
                                   "name", "suggest",
                                   "clientId", "suggest",
                                   "form", form,
                                   "translatedFieldSupport", translator,
                                   "validatableFieldSupport", validator,
                                   "options", "{thisisinvalid:true",
                                   "specification", spec);

        expect(cycle.isRewinding()).andReturn(false).anyTimes();
        expect(resp.isDynamic()).andReturn(false);
        expect(cycle.getAttribute(TapestryUtils.FORM_ATTRIBUTE)).andReturn(form).anyTimes();

        expect(translator.format(comp, null)).andReturn("r2d2");
        translator.renderContributions(comp, writer, cycle);
        validator.renderContributions(comp, writer, cycle);

        expect(binding.getObject()).andReturn("{thisisinvalid:true");
        expect(binding.getLocation()).andReturn(l);

        replay();
View Full Code Here

public class TestDropdownTimePicker extends BaseFormComponentTestCase
{

    public void test_Render()
    {
        ValidatableFieldSupport vfs = newMock(ValidatableFieldSupport.class);
        DateTranslator translator = new DateTranslator();
        translator.setPattern("hh:mm a");
        ResponseBuilder resp = newMock(ResponseBuilder.class);

        IRequestCycle cycle = newMock(IRequestCycle.class);
        IForm form = newMock(IForm.class);
        checkOrder(form, false);
        IPage page = newPage();
        Locale locale = Locale.getDefault();

        MockDelegate delegate = new MockDelegate();

        IScript script = newMock(IScript.class);

        Date dtValue = new Date();

        DropdownTimePicker component = newInstance(DropdownTimePicker.class,
                                                   "name", "fred",
                                                   "script", script,
                                                   "validatableFieldSupport", vfs,
                                                   "translator", translator,
                                                   "value", dtValue,
                                                   "page", page);

        expect(cycle.renderStackPush(component)).andReturn(component);
        expect(form.getName()).andReturn("testform").anyTimes();

        form.setFormFieldUpdating(true);

        IMarkupWriter writer = newBufferWriter();

        trainGetForm(cycle, form);
        trainWasPrerendered(form, writer, component, false);

        trainGetDelegate(form, delegate);

        delegate.setFormComponent(component);

        trainGetElementId(form, component, "fred");
        trainIsRewinding(form, false);
        expect(cycle.isRewinding()).andReturn(false).anyTimes();

        delegate.setFormComponent(component);

        expect(cycle.getResponseBuilder()).andReturn(resp).anyTimes();
        expect(resp.isDynamic()).andReturn(false).anyTimes();

        vfs.renderContributions(component, writer, cycle);

        expect(page.getLocale()).andReturn(locale).anyTimes();

        PageRenderSupport prs = newPageRenderSupport();
        trainGetPageRenderSupport(cycle, prs);
View Full Code Here

public class TestDropdownTimePicker extends BaseFormComponentTestCase
{
   
    public void test_Render()
    {
        ValidatableFieldSupport vfs = newMock(ValidatableFieldSupport.class);
        DateTranslator translator = new DateTranslator();
        translator.setPattern("hh:mm a");
        ResponseBuilder resp = newMock(ResponseBuilder.class);
       
        IRequestCycle cycle = newMock(IRequestCycle.class);
        IForm form = newMock(IForm.class);
        checkOrder(form, false);
        IPage page = newPage();
       
        MockDelegate delegate = new MockDelegate();
       
        IScript script = newMock(IScript.class);
       
        Date dtValue = new Date();
       
        DropdownTimePicker component = newInstance(DropdownTimePicker.class,
                new Object[] {
            "name", "fred",
            "script", script,
            "validatableFieldSupport", vfs,
            "translator", translator,
            "value", dtValue,
            "page", page
        });
       
        expect(cycle.renderStackPush(component)).andReturn(component);
       
        expect(form.getName()).andReturn("testform").anyTimes();
       
        form.setFormFieldUpdating(true);
       
        IMarkupWriter writer = newBufferWriter();
       
        trainGetForm(cycle, form);
        trainWasPrerendered(form, writer, component, false);
       
        trainGetDelegate(form, delegate);
       
        delegate.setFormComponent(component);
       
        trainGetElementId(form, component, "fred");
        trainIsRewinding(form, false);
        expect(cycle.isRewinding()).andReturn(false).anyTimes();
       
        delegate.setFormComponent(component);
       
        expect(cycle.getResponseBuilder()).andReturn(resp).anyTimes();
        expect(resp.isDynamic()).andReturn(false).anyTimes();
       
        vfs.renderContributions(component, writer, cycle);
       
        PageRenderSupport prs = newPageRenderSupport();
        trainGetPageRenderSupport(cycle, prs);
       
        script.execute(eq(component), eq(cycle), eq(prs), isA(Map.class));
View Full Code Here

    }
   
    public void test_Rewind()
    {
        IAutocompleteModel model = createModel();
        ValidatableFieldSupport vfs = newMock(ValidatableFieldSupport.class);
        DataSqueezer ds = newMock(DataSqueezer.class);
       
        Autocompleter component = newInstance(Autocompleter.class,
                new Object[] { "model", model, "validatableFieldSupport", vfs,
            "dataSqueezer", ds});
       
        IRequestCycle cycle = newMock(IRequestCycle.class);
        IForm form = newMock(IForm.class);
       
        IMarkupWriter writer = newWriter();
       
        IValidationDelegate delegate = newDelegate();
       
        expect(cycle.renderStackPush(component)).andReturn(component);
       
        trainGetForm(cycle, form);
        trainWasPrerendered(form, writer, component, false);
        trainGetDelegate(form, delegate);
       
        delegate.setFormComponent(component);
       
        trainGetElementId(form, component, "barney");
        trainIsRewinding(form, true);
       
        trainGetParameter(cycle, "barney", "1");
       
        expect(ds.unsqueeze("1")).andReturn(new Integer(1));
       
        SimpleBean match = new SimpleBean(new Integer(1), null, -1);
       
        try
        {
            vfs.validate(component, writer, cycle, match);
        }
        catch (ValidatorException e)
        {
            unreachable();
        }
View Full Code Here

TOP

Related Classes of org.apache.tapestry.form.ValidatableFieldSupport

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.