Search in sources :

Example 1 with FormSupport

use of org.apache.tapestry5.services.FormSupport in project flowlogix by flowlogix.

the class DisableAfterSubmit method enableSubmitProcessing.

public static void enableSubmitProcessing(ClientElement clientElement, FormSupport fs, JavaScriptSupport js) {
    JSONObject spec = new JSONObject();
    spec.put("elementId", clientElement.getClientId());
    spec.put("formId", fs.getClientId());
    js.addInitializerCall("disableAfterSubmit", spec);
}
Also used : JSONObject(org.apache.tapestry5.json.JSONObject)

Example 2 with FormSupport

use of org.apache.tapestry5.services.FormSupport in project tapestry-5 by apache.

the class UploadTest method begin_render_writes_input_tag.

@Test
public void begin_render_writes_input_tag() throws Exception {
    MarkupWriter writer = createMarkupWriter();
    writer.element("form");
    FormSupport formSupport = mockFormSupport();
    ComponentResources resources = mockComponentResources();
    FieldValidator validator = mockFieldValidator();
    Request request = mockRequest();
    train_isXHR(request, false);
    formSupport.setEncodingType(Upload.MULTIPART_ENCTYPE);
    validator.render(writer);
    resources.renderInformalParameters(writer);
    replay();
    Upload component = new Upload(null, null, null, null, resources, null);
    component.injectDecorator(new BaseValidationDecorator()).injectFormSupport(formSupport).injectFieldValidator(validator).injectRequest(request);
    component.beginRender(writer);
    Element element = writer.getElement();
    assertNotNull(element);
    assertEquals(element.getName(), "input");
    assertEquals(element.getAttribute("type"), "file");
    // assertEquals(element.getAttribute("name"),null);
    // assertEquals(element.getAttribute("id"),null);
    verify();
}
Also used : Element(org.apache.tapestry5.dom.Element) Request(org.apache.tapestry5.http.services.Request) FormSupport(org.apache.tapestry5.services.FormSupport) Test(org.testng.annotations.Test)

Example 3 with FormSupport

use of org.apache.tapestry5.services.FormSupport in project tapestry-5 by apache.

the class UploadTest method validation_decorator_invoked_inside_begin_render.

@Test
public void validation_decorator_invoked_inside_begin_render() throws Exception {
    getMocksControl().checkOrder(true);
    ComponentResources resources = mockComponentResources();
    Upload component = new Upload(null, null, null, null, resources, null);
    MarkupWriter writer = createMarkupWriter();
    writer.element("form");
    FieldValidator validator = mockFieldValidator();
    Request request = mockRequest();
    FormSupport formSupport = mockFormSupport();
    formSupport.setEncodingType(Upload.MULTIPART_ENCTYPE);
    component.injectFormSupport(formSupport).injectRequest(request);
    ValidationDecorator decorator = mockValidationDecorator();
    component.injectDecorator(decorator).injectFieldValidator(validator);
    validator.render(writer);
    resources.renderInformalParameters(writer);
    decorator.insideField(component);
    train_isXHR(request, false);
    replay();
    component.beginRender(writer);
    verify();
}
Also used : Request(org.apache.tapestry5.http.services.Request) FormSupport(org.apache.tapestry5.services.FormSupport) Test(org.testng.annotations.Test)

Example 4 with FormSupport

use of org.apache.tapestry5.services.FormSupport in project tapestry-5 by apache.

the class SubmitTest method test_imagesubmit_event_fired.

@Test
public void test_imagesubmit_event_fired() {
    Request request = mockRequest();
    final ComponentResources resources = mockComponentResources();
    FormSupport formSupport = mockFormSupport();
    Asset image = mockAsset();
    String elementName = "myname";
    train_getParameter(request, Form.SUBMITTING_ELEMENT_ID, null);
    train_getParameter(request, elementName + ".x", "15");
    formSupport.defer(isA(Runnable.class));
    replay();
    Submit submit = new Submit(request);
    TestBase.set(submit, "resources", resources, "formSupport", formSupport, "image", image);
    submit.processSubmission("xyz", elementName);
    verify();
}
Also used : Request(org.apache.tapestry5.http.services.Request) Asset(org.apache.tapestry5.Asset) FormSupport(org.apache.tapestry5.services.FormSupport) ComponentResources(org.apache.tapestry5.ComponentResources) Test(org.testng.annotations.Test)

Example 5 with FormSupport

use of org.apache.tapestry5.services.FormSupport in project tapestry-5 by apache.

the class SubmitTest method test_submit_event_fired.

@Test
public void test_submit_event_fired() {
    Request request = mockRequest();
    final ComponentResources resources = mockComponentResources();
    FormSupport formSupport = mockFormSupport();
    String elementName = "myname";
    train_getParameter(request, Form.SUBMITTING_ELEMENT_ID, null);
    train_getParameter(request, elementName, "login");
    formSupport.defer(isA(Runnable.class));
    replay();
    Submit submit = new Submit(request);
    TestBase.set(submit, "resources", resources, "formSupport", formSupport);
    submit.processSubmission("xyz", elementName);
    verify();
}
Also used : Request(org.apache.tapestry5.http.services.Request) FormSupport(org.apache.tapestry5.services.FormSupport) ComponentResources(org.apache.tapestry5.ComponentResources) Test(org.testng.annotations.Test)

Aggregations

FormSupport (org.apache.tapestry5.services.FormSupport)22 Test (org.testng.annotations.Test)22 ComponentResources (org.apache.tapestry5.ComponentResources)15 MessageFormatter (org.apache.tapestry5.commons.MessageFormatter)15 Messages (org.apache.tapestry5.commons.Messages)15 FieldValidator (org.apache.tapestry5.FieldValidator)12 Validator (org.apache.tapestry5.Validator)11 TypeCoercer (org.apache.tapestry5.commons.services.TypeCoercer)10 FieldValidatorSource (org.apache.tapestry5.services.FieldValidatorSource)10 ValidatorMacro (org.apache.tapestry5.validator.ValidatorMacro)10 Request (org.apache.tapestry5.http.services.Request)7 FieldTranslator (org.apache.tapestry5.FieldTranslator)5 MarkupWriter (org.apache.tapestry5.MarkupWriter)5 Translator (org.apache.tapestry5.Translator)5 FieldTranslatorSource (org.apache.tapestry5.services.FieldTranslatorSource)5 TranslatorSource (org.apache.tapestry5.services.TranslatorSource)5 Locale (java.util.Locale)4 Map (java.util.Map)4 Field (org.apache.tapestry5.Field)4 AnnotationProvider (org.apache.tapestry5.commons.AnnotationProvider)4