Package org.apache.tapestry.form

Examples of org.apache.tapestry.form.FormComponentContributorContext


        IRequestCycle cycle = newCycle();
        JSONObject json = new JSONObject();
       
        IFormComponent field = newField("My Field", "customField");
       
        FormComponentContributorContext context = newMock(FormComponentContributorContext.class);

        expect(context.getProfile()).andReturn(json);
       
        trainFormatMessage(
                context,
                "custom",
                ValidationStrings.VALUE_TOO_SHORT,
View Full Code Here


    public void test_Palette_Required()
    {
        ValidatableFieldSupport vfs = newMock(ValidatableFieldSupport.class);
        IRequestCycle cycle = newCycle();
        FormComponentContributorContext context = newMock(FormComponentContributorContext.class);
        IMarkupWriter writer = newWriter();
       
        JSONObject profile = new JSONObject();
        Required required = new Required("message=Field {0} is required.");
       
        Palette component = newInstance(Palette.class,
                new Object[] {
            "validatableFieldSupport", vfs,
            "clientId", "pal", "displayName", "Pally"});
       
        expect(context.getProfile()).andReturn(profile);
       
        expect(context.formatValidationMessage(eq(required.getMessage()), eq(ValidationStrings.REQUIRED_FIELD),
                aryEq(new Object[] { "Pally" }) )).andReturn("Pally is required.");
       
        replay();
       
        assert component.overrideValidator(required, cycle);
View Full Code Here

        IMarkupWriter writer = newWriter();
        IRequestCycle cycle = newCycle();
       
        JSONObject json = new JSONObject();
       
        FormComponentContributorContext context = newMock(FormComponentContributorContext.class);
       
        expect(context.getProfile()).andReturn(json);
       
        IFormComponent field = newFieldWithClientId("myfield");
       
        replay();
View Full Code Here

        JSONObject json = new JSONObject();
       
        IMarkupWriter writer = newWriter();
        IRequestCycle cycle = newCycle();
       
        FormComponentContributorContext context = newMock(FormComponentContributorContext.class);
       
        expect(context.getProfile()).andReturn(json);
       
        trainGetLocale(context, Locale.ENGLISH);
       
        trainBuildMessage(context, null, ValidationStrings.INVALID_DATE,
                new Object[] { "Date Field",
                translator.getDateFormat(Locale.ENGLISH)
                .toLocalizedPattern().toUpperCase(Locale.ENGLISH)}, "invalid date");
       
        context.addInitializationScript(field, "dojo.require(\"tapestry.form.datetime\");");
       
        replay();
       
        translator.renderContribution(writer, cycle, context, field);
       
View Full Code Here

        IRequestCycle cycle = newCycle();
        IFormComponent field = newField("Date Field", "dateField", 1);
       
        JSONObject json = new JSONObject();
       
        FormComponentContributorContext context = newMock(FormComponentContributorContext.class);
       
        expect(context.getProfile()).andReturn(json).anyTimes();
       
        trainGetLocale(context, Locale.ENGLISH);
       
        trainBuildMessage(context, null, ValidationStrings.INVALID_DATE,
                new Object[] { "Date Field",
                dt.getDateFormat(Locale.ENGLISH)
                .toLocalizedPattern().toUpperCase(Locale.ENGLISH)}, "invalid date");
       
        context.addInitializationScript(field, "dojo.require(\"tapestry.form.datetime\");");
       
        replay();

        dt.renderContribution(writer, cycle, context, field);
View Full Code Here

    public void test_Render_Contribution()
    {
        IMarkupWriter writer = newWriter();
        IRequestCycle cycle = newCycle();
        JSONObject json = new JSONObject();
        FormComponentContributorContext context = newMock(FormComponentContributorContext.class);
        IFormComponent field = newField("My Field", "myfield");

        Locale locale = Locale.FRANCE;
        DecimalFormatSymbols symbols = new DecimalFormatSymbols(locale);
       
        expect(context.getLocale()).andReturn(locale).atLeastOnce();
        expect(context.getProfile()).andReturn(json);
       
        trainFormatMessage(context, null, ValidationStrings.VALUE_TOO_SMALL, new Object[]
        { "My Field", String.valueOf(new Double(20).doubleValue())}, "default message");
       
        replay();
View Full Code Here

    public void test_Render_Contribution_Custom_Message()
    {
        IMarkupWriter writer = newWriter();
        IRequestCycle cycle = newCycle();
        JSONObject json = new JSONObject();
        FormComponentContributorContext context = newMock(FormComponentContributorContext.class);
        IFormComponent field = newField("My Field", "myfield");

        Locale locale = Locale.FRANCE;
        DecimalFormatSymbols symbols = new DecimalFormatSymbols(locale);
       
        expect(context.getLocale()).andReturn(locale).atLeastOnce();
        expect(context.getProfile()).andReturn(json);
       
        trainFormatMessage(
                context,
                "custom",
                ValidationStrings.VALUE_TOO_SMALL,
View Full Code Here

       
        expect(field.getClientId()).andReturn("myfield").anyTimes();
       
        expect(field.getDisplayName()).andReturn("My Field");
       
        FormComponentContributorContext context = newMock(FormComponentContributorContext.class);
       
        Locale locale = Locale.ENGLISH;
        expect(context.getLocale()).andReturn(locale).anyTimes();
       
        expect(context.getProfile()).andReturn(json);
       
        context.addInitializationScript(field, "dojo.require(\"tapestry.form.datetime\");");
       
        String strMax = translator.format(field, locale, maxDate);
       
        trainFormatMessage(context, null, ValidationStrings.DATE_TOO_LATE,
                new Object[] { "My Field", strMax }, "default message");
View Full Code Here

       
        expect(field.getClientId()).andReturn("myfield").anyTimes();
       
        expect(field.getDisplayName()).andReturn("My Field");
       
        FormComponentContributorContext context = newMock(FormComponentContributorContext.class);
       
        Locale locale = Locale.ENGLISH;
        expect(context.getLocale()).andReturn(locale).anyTimes();
       
        expect(context.getProfile()).andReturn(json);
       
        context.addInitializationScript(field, "dojo.require(\"tapestry.form.datetime\");");
       
        String strMax = translator.format(field, locale, maxDate);
       
        trainFormatMessage(context, "custom", ValidationStrings.DATE_TOO_LATE,
                new Object[] { "My Field", strMax },
View Full Code Here

    {
        IMarkupWriter writer = newWriter();
        IRequestCycle cycle = newCycle();
        IFormComponent field = newField("My Field", "myfield");
        MockControl contextc = newControl(FormComponentContributorContext.class);
        FormComponentContributorContext context = (FormComponentContributorContext) contextc
                .getMock();

        context.includeClasspathScript("/org/apache/tapestry/form/validator/StringValidator.js");

        trainFormatMessage(contextc, context, null, ValidationStrings.VALUE_TOO_SHORT, new Object[]
        { new Integer(20), "My Field" }, "default message");

        context
                .addSubmitHandler("function(event) { Tapestry.validate_min_length(event, 'myfield', 20, 'default message'); }");

        replayControls();

        new MinLength("minLength=20").renderContribution(writer, cycle, context, field);
View Full Code Here

TOP

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

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.