Package com.volantis.mcs.protocols

Examples of com.volantis.mcs.protocols.XFActionAttributes



    public void testDoActionInputWithoutForm() throws ProtocolException {
        privateSetUp();
        testable.setPageHead(new TestPageHead(protocol));
        XFActionAttributes attributes = new XFActionAttributes();
        attributes.setStyles(StylesBuilder.getInitialValueStyles());
        attributes.setFormAttributes(null);
        attributes.setName("TestAction");
        protocol.doActionInput(buffer, attributes);
        assertTrue(buffer.getCurrentElement().getName()==null);
        assertNull(protocol.getPageHead().getAttribute("wtv_connect_now"));
    }
View Full Code Here


    }

    public void testDoActionInputWithForm() throws ProtocolException {
        privateSetUp();
        testable.setPageHead(new TestPageHead(protocol));
        XFActionAttributes attributes = new XFActionAttributes();
        attributes.setStyles(StylesBuilder.getInitialValueStyles());

        XFFormAttributes formAttributes = new XFFormAttributes();
        Form form = new Form(new CanvasLayout());
        FormInstance formInstance = new FormInstance(
                NDimensionalIndex.ZERO_DIMENSIONS);
        formInstance.setFormat(form);
        formAttributes.setAction(new LiteralLinkAssetReference("testaction"));
        formAttributes.setFormData(formInstance);
        formAttributes.setMethod("post");
        formAttributes.setFormSpecifier("test");
        attributes.setFormAttributes(formAttributes);
        attributes.setName("TestAction");
        attributes.setType("submit");
        protocol.doActionInput(buffer, attributes);
        Element element = buffer.getCurrentElement();
        assertEquals(null, element.getName());
        document.addNode(element);
        try {
View Full Code Here

     */
    public void testActionInput() throws Exception {
        DOMOutputBuffer buffer = new DOMOutputBuffer();
        buffer.initialise();

        XFActionAttributes attributes = new XFActionAttributes();
        attributes.setStyles(StylesBuilder.getInitialValueStyles());

        // Setup test for action tag located outside form (type=perform)
        String shortcut = "1";
        String name = "My Name";
        String actionType = "perform";
        String caption = "This is my caption";

        attributes.setShortcut(new LiteralTextAssetReference(shortcut));
        attributes.setName(name);
        attributes.setType(actionType);
        attributes.setCaption(new LiteralTextAssetReference(caption));

        protocol.doActionInput(buffer, attributes);
        String actualResult = bufferToString(buffer);

        assertEquals("Ensure that nothing is returned",
View Full Code Here

    // Javadoc inherited
    protected void checkActionInputType() throws ProtocolException {

        DOMOutputBuffer buffer = new DOMOutputBuffer();
        buffer.initialise();
        XFActionAttributes attributes = new XFActionAttributes();
        attributes.setStyles(StylesBuilder.getInitialValueStyles());

        // Setup test for normal behaviour for input tag generation (submit)
        String name = "My Name";
        String actionType = "submit";
        String caption = "This is my caption";
        String value = "This is my value";

        attributes.setName(name);
        attributes.setType(actionType);
        attributes.setCaption(new LiteralTextAssetReference(caption));
        attributes.setValue(value);

        protocol.doActionInput(buffer, attributes);
        String actualResult = bufferToString(buffer);
        assertEquals("DOM buffer should match",
                "<input name=\"" + name + "\" " +
                "type=\"" + actionType + "\" value=\"" + caption + "\"/>",
                actualResult);

        // Setup test for normal behaviour for input tag generation (perform)
        buffer = new DOMOutputBuffer();
        buffer.initialise();
        actionType = "perform";
        attributes.setType(actionType);
        protocol.doActionInput(buffer, attributes);
        actualResult = bufferToString(buffer);
        assertEquals("DOM buffer should match",
                "<input name=\"" + name + "\" " +
                "type=\"" + "submit" + "\" value=\"" + caption + "\"/>",
                actualResult);

        // Setup test for normal behaviour for input tag generation (perform)
        buffer = new DOMOutputBuffer();
        buffer.initialise();
        actionType = "reset";
        attributes.setType(actionType);
        protocol.doActionInput(buffer, attributes);
        actualResult = bufferToString(buffer);
        assertEquals("DOM buffer should match",
                "<input name=\"" + name + "\" " +
                "type=\"" + actionType + "\" value=\"" + caption + "\"/>",
                actualResult);

        // Setup test for abnormal behaviour - garbage actionType
        buffer = new DOMOutputBuffer();
        buffer.initialise();
        actionType = "GARBAGE";
        attributes.setType(actionType);
        try {
            protocol.doActionInput(buffer, attributes);
            fail("Should have thrown an IllegalArgumentException");
        } catch (IllegalArgumentException e) {
        }

        // Setup test for abnormal behaviour - garbage actionType
        buffer = new DOMOutputBuffer();
        buffer.initialise();
        actionType = "submit";
        attributes.setType(actionType);
        attributes.setTabindex("1");
        protocol.doActionInput(buffer, attributes);
        assertTrue(protocol.supportsTabindex);
        actualResult = bufferToString(buffer);
        assertEquals("DOM buffer should match",
                "<input name=\"" + name + "\" " +
View Full Code Here

        String value = "This is my value";

        DOMOutputBuffer buffer = new DOMOutputBuffer();
        buffer.initialise();

        XFActionAttributes attributes = new XFActionAttributes();
        attributes.setStyles(StylesBuilder.getInitialValueStyles());

        attributes.setName(name);
        attributes.setType(actionType);
        attributes.setCaption(new LiteralTextAssetReference(caption));
        attributes.setValue(value);

        // Setup test to ensure that link style form submision fallsback to the
        // default form submision
        protocol.doActionInput(buffer, attributes);
        String actualResult = bufferToString(buffer);
View Full Code Here

    protected void checkActionInputShortcut(boolean generated,
                                            boolean styled) throws ProtocolException {

        DOMOutputBuffer buffer = new DOMOutputBuffer();
        buffer.initialise();
        XFActionAttributes attributes = new XFActionAttributes();
        attributes.setStyles(StylesBuilder.getInitialValueStyles());

        // Setup test for normal behaviour for input tag generation (submit)
        String shortcut = "1";
        String name = "My Name";
        String actionType = "submit";
        String caption = "This is my caption";

        attributes.setShortcut(new LiteralTextAssetReference(shortcut));
        attributes.setName(name);
        attributes.setType(actionType);
        attributes.setCaption(new LiteralTextAssetReference(caption));

        protocol.doActionInput(buffer, attributes);
        String actualResult = bufferToString(buffer);
        assertEquals("DOM buffer should match",
                "<input " +
View Full Code Here

        requestContext.expects.getEnvironmentContext().returns(envContext);
        envContext.expects.getCachingDirectives().returns(null);
        strategy.expects.getCharacterData().returns(VALUE_FROM_BODY);

        XFSubmitElementImpl submitElement = new XFSubmitElementImpl(context);
        XFActionAttributes attributes =
                (XFActionAttributes) submitElement.getProtocolAttributes();
        FieldDescriptor fd = new FieldDescriptor();
        attributes.setFieldDescriptor(fd);
        context.pushElement(submitElement);

        // Run test.
        XFSetValueElementImpl setValue =
                new XFSetValueElementImpl(context, strategy);
View Full Code Here

        requestContext.expects.getEnvironmentContext().returns(envContext);
        envContext.expects.getCachingDirectives().returns(null);
        strategy.expects.getCharacterData().returns(VALUE_FROM_BODY);

        XFSubmitElementImpl submitElement = new XFSubmitElementImpl(context);
        XFActionAttributes actionAttributes =
                (XFActionAttributes) submitElement.getProtocolAttributes();
        FieldDescriptor fd = new FieldDescriptor();
        actionAttributes.setFieldDescriptor(fd);
        context.pushElement(submitElement);

        // Run test.
        assertNull(actionAttributes.getInitial());
        assertNull(actionAttributes.getValue());
        assertNull(actionAttributes.getFieldDescriptor().getInitialValue());
        XFSetValueElementImpl setValue =
                new XFSetValueElementImpl(context, strategy);
        setValue.callOpenOnProtocol(context, attributes);
        setValue.callCloseOnProtocol(context);

        assertEquals(VALUE_FROM_BODY, actionAttributes.getInitial().getText(
                TextEncoding.PLAIN));
        assertEquals(VALUE_FROM_BODY, actionAttributes.getValue());
        assertEquals(VALUE_FROM_BODY,
                actionAttributes.getFieldDescriptor().getInitialValue());
    }
View Full Code Here

        requestContext.expects.getEnvironmentContext().returns(envContext);
        envContext.expects.getCachingDirectives().returns(null);
        strategy.expects.getCharacterData().returns(null);

        XFSubmitElementImpl submitElement = new XFSubmitElementImpl(context);
        XFActionAttributes actionAttributes =
                (XFActionAttributes) submitElement.getProtocolAttributes();
        FieldDescriptor fd = new FieldDescriptor();
        actionAttributes.setFieldDescriptor(fd);
        context.pushElement(submitElement);

        // Run test.
        assertNull(actionAttributes.getInitial());
        assertNull(actionAttributes.getValue());
        assertNull(actionAttributes.getFieldDescriptor().getInitialValue());
        XFSetValueElementImpl setValue =
                new XFSetValueElementImpl(context, strategy);
        setValue.callOpenOnProtocol(context, attributes);
        setValue.callCloseOnProtocol(context);

        assertEquals(VALUE_FROM_ATTRIBUTE, actionAttributes.getInitial().getText(
                TextEncoding.PLAIN));
        assertEquals(VALUE_FROM_ATTRIBUTE, actionAttributes.getValue());
        assertEquals(VALUE_FROM_ATTRIBUTE,
                actionAttributes.getFieldDescriptor().getInitialValue());
    }
View Full Code Here

            // trigger the submission) then HTMLActionFieldHandler appends this
            // name value pair using the name and initial value specified in
            // the field descriptor of the submit element. In order for our
            // parent submit element to set this flag, we should set the
            // initial value to the value specified.
            XFActionAttributes parentAttributes = ((XFActionAttributes)
                    ((XFSubmitElementImpl)element).getProtocolAttributes());
            parentAttributes.setName(name);
            parentAttributes.setInitial(value);
            parentAttributes.setValue(value);
           
            FieldDescriptor fd = parentAttributes.getFieldDescriptor();
            fd.setName(name);
            fd.setInitialValue(value);           
        } else {           
            String localizedException = EXCEPTION_LOCALIZER.format(
                    "xforms-invalid-setvalue-parent",
View Full Code Here

TOP

Related Classes of com.volantis.mcs.protocols.XFActionAttributes

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.